Microduino Traffic Light Simulation

来自Microduino Wikipedia
1304410487@qq.com讨论 | 贡献2015年3月9日 (一) 07:06的版本 (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...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索


Purpose

The course will show you how to use Microduino to simulate a traffic light.

Equipment

Module Number Function
Microduino-Core 1 Core board
Microduino-USBTTL 1 Program download


  • Other equipment
220Ω resistor One
Breadboard jumper One box
USB cable One
Red LED Two
Yellow LED Two
Green LED Two
White LED Two
Breadboard One

Schematic

TrafficLightSechmatic.png

As 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:

TrafficLightSechmaticsw.jpg

Program

[MicroduinoTrafficLight]

Debugging

Step 1: Build the circuit according to the schematic, as follows:

TrafficLight1.png


Step 2: Download the code and run after compiling.

TrafficLight2.png


Step 3: Function description 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 “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 “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
TrafficLight3.jpg

From the crossroads picture above, you can see two traffic lights in this example are in different direction.


Result

Two traffic lights will simulate traffic lights in two directions at the crossroads as well as how they work in real life.

Video

http://v.youku.com/v_show/id_XODQ5NTcwOTg4.html