SainSmart UNO R3 Starter Kit For Arduino
Example code
Program code is in the advertising lights program folder. Double-click to open and you will see a
led2 folder, open it, you will find out a led2.pde file. Double-click the icon to open it. Then you
will see that it is the arduino programming software window with the experimental program
code.
//set in Led’s digital IO pin control
int Led1 = 1;
int Led2 = 2;
int Led3 = 3;
int Led4 = 4;
int Led5 = 5;
int Led6 = 6;
//led lamp run the example 1 program
void style_1(void)
{
unsigned char j;
for(j=1;j<=6;j++)//every 200ms light up one of led lamps with 1~6 pin in turn
{
digitalWrite(j,HIGH);//light up the led lamps with j pin
delay(200);//delay 200ms
}
for(j=6;j>=1;j--)//every 200ms got out one of led lamps with 6~1 pin in turn
digitalWrite(j,LOW);//go out the led lamps with j pin
delay(200);//delay 200ms
}
}
//led lamp blink example program
void flash(void)
{
unsigned char j,k;
for(k=0;k<=1;k++)//blink twice
{
for(j=1;j<=6;j++)//light up led lamps with 1~6 pin
digitalWrite(j,HIGH);//light up led lamp with j pin
delay(200);//delay 200ms
for(j=1;j<=6;j++)//go out the led lamp with 1~6 pin
digitalWrite(j,LOW);//go out the led lamp with j pin
delay(200);//delay 200ms
}
}
//led lamp run the example 2 program
void style_2(void)
{
unsigned char j,k;