Difference between revisions of "Microduino Traffic Light Simulation"
(Created page with "{| style="width: 800px;" |- | ==Purpose== The course will show you how to use Microduino to simulate a traffic light. ==Equipment== {|class="wikitable" |- |Module||Numbe...") |
|||
Line 75: | Line 75: | ||
Step 3: Function description | Step 3: Function description | ||
Here in this example, we simulate two traffic lights and define four circumstances in the code: | Here in this example, we simulate two traffic lights and define four circumstances in the code: | ||
− | 1.When traffic light 1 goes on and the driving lamp blinks, it means | + | 1.When traffic light 1 goes on and the driving lamp blinks, it means "Stop"; At same the time, the second green light in traffic light 2 goes on, it means "Go". |
− | 2.When the red light goes off and the yellow light goes on in traffic light 1, it means | + | 2.When the red light goes off and the yellow light goes on in traffic light 1, it means "Ready to go". At the same time, the yellow light in traffic light 2 goes on, meaning "Ready to stop". |
− | 3.When green light in traffic light 1 goes on, it means | + | 3.When green light in traffic light 1 goes on, it means "Go". The red light goes on and driving lamp blinks in traffic light 2, it means "Stop". |
− | 4.When the yellow light in traffic light goes on, it means | + | 4.When the yellow light in traffic light goes on, it means "Read to stop". Meantime, the red light goes off and yellow light goes on in traffic light 2, it means "Ready to go". |
− | The variable | + | The variable "duration" in the code defines duration time of each circumstance: |
int duration[] = { | int duration[] = { |
Latest revision as of 08:47, 13 September 2016
PurposeThe course will show you how to use Microduino to simulate a traffic light. Equipment
SchematicAs the pictures show: Red light—Stop Yellow—Wait to turn color Green—Go The driving light—white light together with blinking red light reminds pedestrians to stop. Just like this: ProgramDebuggingStep 1: Build the circuit according to the schematic, as follows:
2.When the red light goes off and the yellow light goes on in traffic light 1, it means "Ready to go". At the same time, the yellow light in traffic light 2 goes on, meaning "Ready to stop". 3.When green light in traffic light 1 goes on, it means "Go". The red light goes on and driving lamp blinks in traffic light 2, it means "Stop". 4.When the yellow light in traffic light goes on, it means "Read to stop". Meantime, the red light goes off and yellow light goes on in traffic light 2, it means "Ready to go". The variable "duration" in the code defines duration time of each circumstance: int duration[] = { 8000,3000,10000,3000}; // duration of each situation From the crossroads picture above, you can see two traffic lights in this example are in different direction.
ResultTwo traffic lights will simulate traffic lights in two directions at the crossroads as well as how they work in real life. Video |