Example of a state machine


hi all,

thought i'd share this.

i implemented state machine turnstile (i prefer turnstyle wth, no biggy....)  based on read here. attached code commented in essence takes care of these events:

current     event    transition   new
  state                            state
-------------------------------------------
locked      coin     unlock       unlocked (normal operation)
unlocked    pass     lock         locked   (normal operation)
locked      pass     alarm        locked   (abnormal operation: forced entry)
unlocked    coin           unlocked (abnormal operation: paid twice)


in nutshell, starts locked, pay, unlocks, open, enter, close , locks. if pay when it's unlocked, donation, paid twice. if open without paying, alarm.

my turnstile isn't mechanically correct: it's short metal strip on hinge. 1 end rests on electromagnet, , there's optointerrupter half way along. optoint detects presence of strip, magnet locks in place. lifting strip pushing turnstile, dropping stile closing behind you. can lift strip against magnet simulate illegal entry.

payment clicking software debounced momentary switch, simulates coin drop.

this implementation not worry stile being open, ie sort of hovering between  "clicks"; perhaps phaseii , alarm on timeout, meaning trapped or didn't click closed properly.

you're welcome whatever this.....

eagle schematic added.

current limiting resistors on leds , q not shown.


Arduino Forum > Community > Exhibition / Gallery > Example of a state machine


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support