The following diagram demonstrates the flow of our software:
Our software was designed as a finite state machine using the following states:
State 1: Sit idle for 2 seconds and then increment the state.
State 2: Follow the wall on the right while using the distance sensors to determine corrections needed to the position of the robot. This wall following will cause the robot to drive to the end of the hallway and then turn around and come back. While navigating the hallway, constantly take readings from the phototransistors to determine whether or not a candle has been found. If a candle has been found, go to state 5. If the candle has not been found, continue in this state until the reading from the distance sensor on the right suddenly drops to a value below 0.1 V. This voltage drop lets our robot know that the door has been found. Increment the state.
State 3: Go forward about a foot to get to the center of the door and then turn right. Go forward a few more feet while using object avoidance to get next to the center console. Increment the state.
State 4: Circle around the center console by using the distance sensors to avoid objects and to look for open areas to drive into. Constantly take readings from the phototransistors to determine whether or not a candle has been found. If a candle has been found, go to state 5.
State 5: Position the robot to make it face the candle. Go to state 6.
State 6: Use the temperature sensor to determine if the flame is real. If it is, go to state 7. If not, go back to state 2 or 4, depending on whether the robot is in the hallway or in the room.
State 7: Trigger the pump to spray water on the fire. Go to state 8.
State 8: Sit idle.