KS0310 Keyestudio Traffic Light Module (Black and Eco-friendly)
Revision as of 08:27, 8 March 2018 by Keyestudio (talk | contribs) (Created page with " == Keyestudio Traffic Light Module (Black and Eco-friendly) == <br>500px|frameless|thumb<br> == Introduction == When learning the microcontroller, you ma...")
Keyestudio Traffic Light Module (Black and Eco-friendly)
Introduction
When learning the microcontroller, you may usually use three LEDs, namely red, green and yellow light to simulate the traffic light blinking via external connection. So we specially design this module which is very convenient for wiring, and on the module you can see the red, yellow and green LED. This module is fully compatible with Arduino microcontroller and raspberry pi system.
Specification
- Working Voltage: 3.3-5v
- Interface Type: digital
- PH2.54 Socket
- Enable interaction with light-related works
Connection Diagram
Sample Code
int redled =5; // initialize digital pin 5. int yellowled =4; // initialize digital pin 4. int greenled =3; // initialize digital pin 3. void setup() { pinMode(redled, OUTPUT);// set the pin with red LED as “output” pinMode(yellowled, OUTPUT); // set the pin with yellow LED as “output” pinMode(greenled, OUTPUT); // set the pin with green LED as “output” } void loop() { digitalWrite(greenled, HIGH);//// turn on green LED delay(5000);// wait 5 seconds digitalWrite(greenled, LOW); // turn off green LED for(int i=0;i<3;i++)// blinks for 3 times { delay(500);// wait 0.5 seconds digitalWrite(yellowled, HIGH);// turn on yellow LED delay(500);// wait 0.5 seconds digitalWrite(yellowled, LOW);// turn off yellow LED } delay(500);// wait 0.5 seconds digitalWrite(redled, HIGH);// turn on red LED delay(5000);// wait 5 seconds digitalWrite(redled, LOW);// turn off red LED }
Test Result
Done uploading the code, powered up, three LEDs on the module will automatically simulate the traffic light running.