keyestudio
www.keyestudio.cc
29
Sample program
Since it is a simulation of traffic lights, the blinking time of each LED should be the same with
those in traffic lights system. In this program, we use Arduino delay () function to control delay
time, which is much simpler than C language.
//////////////////////////////////////////////////////////
int redled =10; // initialize digital pin 8.
int yellowled =7; // initialize digital pin 7.
int greenled =4; // initialize digital pin 4.
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
Summary of Contents for ARDUINO maker learning kit
Page 1: ...keyestudio www keyestudio cc ARDUINO maker learning kit...
Page 23: ...keyestudio www keyestudio cc 21 Connection for 2560 R3...
Page 30: ...keyestudio www keyestudio cc 28 Connection for 2560 R3...
Page 39: ...keyestudio www keyestudio cc 37 Connection for 2560 R3...
Page 43: ...keyestudio www keyestudio cc 41 Connection for 2560 R3...
Page 46: ...keyestudio www keyestudio cc 44 Connection for 2560 R3...
Page 50: ...keyestudio www keyestudio cc 48 Connection for 2560 R3...
Page 58: ...keyestudio www keyestudio cc 56 Connection for 2560 R3...
Page 62: ...keyestudio www keyestudio cc 60 Connection for 2560 R3...
Page 65: ...keyestudio www keyestudio cc 63 Circuit connection Connection for R3...
Page 66: ...keyestudio www keyestudio cc 64 Connection for 2560 R3...
Page 69: ...keyestudio www keyestudio cc 67 Pic 2 Project 15 LM35 temperature sensor...
Page 71: ...keyestudio www keyestudio cc 69 Connection for 2560 R3 Sample program...
Page 74: ...keyestudio www keyestudio cc 72 Schematic diagram...
Page 77: ...keyestudio www keyestudio cc 75 Circuit connection Connection for R3...
Page 78: ...keyestudio www keyestudio cc 76 Connection for 2560 R3...
Page 80: ...keyestudio www keyestudio cc 78 Result...
Page 82: ...keyestudio www keyestudio cc 80 Connection for 2560 R3...
Page 85: ...keyestudio www keyestudio cc 83 Schematic diagram Circuit connection Connection for R3...
Page 91: ...keyestudio www keyestudio cc 89 Circuit connection Connection for R3...
Page 92: ...keyestudio www keyestudio cc 90 Connection for 2560 R3...
Page 95: ...keyestudio www keyestudio cc 93...
Page 96: ...keyestudio www keyestudio cc 94...
Page 104: ...keyestudio www keyestudio cc 102 Connection for 2560 R3...
Page 111: ...keyestudio www keyestudio cc 109 Connection for R3 Connection for 2560 R3...
Page 120: ...keyestudio www keyestudio cc 118 Connection for 2560 R3...
Page 124: ...keyestudio www keyestudio cc 122 Connection for R3 Connection for 2560 R3...
Page 135: ...keyestudio www keyestudio cc 133 Connection for R3 Connection for 2560 R3...
Page 139: ...keyestudio www keyestudio cc 137 Circuit connection Connection for uno R3...
Page 140: ...keyestudio www keyestudio cc 138 Connection for 2560 R3...
Page 144: ...keyestudio www keyestudio cc 142 Circuit connection Connection for R3...
Page 145: ...keyestudio www keyestudio cc 143 Connection for 2560 R3...
Page 148: ...keyestudio www keyestudio cc 146 Connection for 2560 R3 Sample program...
Page 155: ...keyestudio www keyestudio cc 153 Circuit connection Connection for R3...
Page 156: ...keyestudio www keyestudio cc 154 Connection for 2560 R3...
Page 160: ...keyestudio www keyestudio cc 158 Connection for 2560 R3...