Archive for the 8. Finite State Machines Category

Traffic Intersection Simulation

Posted in 8. Finite State Machines on December 17, 2009 by Andrew Ngan

For my Finite State Machine, I made a traffic intersection simulation. Basically it manages traffic flow at the point of intersection. I used green LED as a traffic light to signal “GO” for cars, and pressure sensor to detect traffic flow at the point of intersection.
State 1: Sensor detects cars on a lane
State 2: Other sensor check cars on the crossing lane
State 3: Gives signal
State 4: Back to State 1

*Both sensors check cars simultaneously, lane with green light has priority. Light off represents red light; blinking light represents yellow; solid green represents green. 1 second is allowed before yellow light on the crossing lane to let car pass intersection before light changes entirely.

Arduino Sketch: traffic_sim


IKEA Virtual Wall (MTI-8)

Posted in 8. Finite State Machines on November 4, 2009 by ryun

I built a IKEA Virtual Wall. I used RFID reader and this detects cards on which RFID tags are attached. You scan your cards then the system will show the related item and go to a certain state such as floor-lamp state, book-shelf state and so on. When you are on each state, if you use IR controller, press the button and move it, then the item on the screen will move around accordingly.
Wiimote detects IR led and send data to the computer in real-time via bluetooth(used Processing to get the data). Phidget RFID reader reads the RFID tags and send signal via USB(used Flash to get the data). And I finally used actionscript 3.0 to use the data to design the interface.


High-Five Machine

Posted in 8. Finite State Machines on November 2, 2009 by zingzhang

This robot was pretty neat, I thought it was rather humorous too. The point of the robot was to give out high-fives. The three states are rest, standby and high-fiving. There are two IR sensors in the system. One of them detects if anyone is near and another detects if a hand is in position for a high-five. The three states are determined by these two IR sensors.

When no one is near either sensor, the system is in rest state, where the hand is stretched out parallel to the floor. When someone is near the system (triggering one IR sensor), the hand raises up and is in standby mode. At this point, it is waiting to get a high-five. When you put your hand next to the robot’s hand, it will trigger the second IR sensor and slap your hand.

circuit board... kinda

Arduino Sketch: High-Five Robot!

State Machine: Trick or Treat

Posted in 8. Finite State Machines on November 2, 2009 by ndoiron

This Halloween themed state machine has two of the more obvious states (trick vs. treat) and a third, more passive state (no one is at the door).

The planned sensors and actuators are shown in this Paint diagram:
Oreo Trick or Treat

When someone arrives at the door, the program leaves the passive “no one at door” state. The visitor makes their intentions clear with a switch (trick vs. treat) which is displayed on a lit sign. In the “treat” state, the dispenser rolls out a tray of Oreo cookies. When the visitor leaves, the passive state resumes and the tray retracts. The “trick” state isn’t particularly useful with the current actuators; mostly it waits for the trickster to leave or request a treat.

I built all of the parts and programmed them, but the Oreo-dispenser doesn’t work on its own.

The Oreo Dispenser
Oreo-Serving Servo

The Door
Picture 24

The Circuit Board
Picture 25

Download Code

shy rabbit

Posted in 8. Finite State Machines on October 29, 2009 by ellenwu

the shy rabbit has 3 states:
1. approach and avoid:
the IR sensor detects certain distance range. if someone invades the rabbit’s territory, the servo motor rotates at a random angle while the turning direction is based on current position, resulting in an ignore behavior.
2. kiss and blush:
the photo sensor detects certain threshold. if someone kisses the rabbit on the cheek, namely, covers the photo sensor, the LEDs start pulsing like a blush.
3. touch and nervous:
the tilt sensor acts as a switch. if someone touch the rabbit by bending its ear, the DC motor starts rotating like a shivering tail.

the states are basically independent, although my intention was to make it behave differently according to proximity.

materials include tilt sensor, photo sensor, IR sensor, DC motor, servo motor, LEDs, resisters, TIP 120, batteries… i did this intentionally to practice most of what we’ve covered in class.

jumpers are annoying :(

rabbit circuit

Arduino Sketch: Wu_shy rabbit

Assignment 8: Good boy sometimes Naughty

Posted in 8. Finite State Machines on October 29, 2009 by yuebinyu

With this assignment about finite state, I plan to practice some more programming with Arduino.

Those are:
Timing with Arduino, state switching, random number generation, function call and external interrupts.

Here a servo is defined to simulate a little kid. An aluminum hand is the most active part of this little kid. Usually he is very good, but can get naughty too.

A set of action is taught via a potentiometer. The value is mapped to (0,180). Once the action is done, kid memorizes it.

He has four states, but one means inactive since the kid got to sleep:
a. Good and listen to you. He repeats what you show him; Waive hand and repeat right the action you taught.
b. Naughty and wont reponse, until you are done then repeat what you show him; When he got tired be naughty, and you did not yell him, he goes on his own– self learning.
c. Self learning. He randomly do some things like you do not exist, pay no attention to you until you yell at him.. hope not.
d. Rest and sleep. He does not do anything in this state. A photo-sensor is used to check this status.

Parts list:
1. Arduino, 1 unit;
2. Servo motor, 1 unit;
3. diode, 1, resistor, 5, transistor, 1;
4. Aluminum hand, 1;
5. Potentiometer, 1;
6. Switches, 4;
7. Cables, 13.

Below is the FSM flow chart:


FSM Flow chart

Main states: active and inactive; within active mode, there are three states: good, naughty, selflearning.
There are four switches defined: yell button( ext_1); harsh button, loose button, sleep button ( ext_0).

Arduino code here: Arduino Sketch: Assignment_8

Below are the parts:




Leds, transistor, resistors, push buttons, etc


Basic control set

Here are screen shot examples:


Mode switch-1

Mode switch-2

Here is the video:

Assignment 8

Posted in 8. Finite State Machines on October 29, 2009 by Aaron Chenault

I based this assignment off of my idea for assignment 6.  The person starts off “asleep,” or lying down.  When the photoresistor detects an increase of light, the person “wakes up,” sitting up.  The person can wake up in two different states, however.  If the photoresistor detects a lot of light, the person wakes up angry, and his eyes are red.  If the photoresistor detects more moderate amounts of light, the person wakes up happy, and his eyes are green.   The program resets itself automatically after 5 seconds.

The construction is simple enough.  You’ll need:


19 Gauge Wire



3 LEDs (Green, Red, White)

Servo Motor


Jumper wires, various resistors


 Just attach a short (2″-3″) piece of wire to the servo, and embed the servo into a wall of foamcore.  Cut out a chipboard person, including holes for the eyes, and hot glue it to the wire.  I found that by adding a second wall of foamcore closer to the chipboard person, I could ensure that the LEDs would only shine through the chipboard person’s eyes, and would not create a “halo” around the chipboard person’s head.

Here’s my code: