
keyestudio
www.keyestudio.cc
38
Sample program
After the connection, let's begin the program compiling. The program is similar to the
one of PWM. For change detail, please refer to the sample program below.
//////////////////////////////////////////////////////////
int potpin=0;// initialize analog pin 0, connected with photovaristor
int ledpin=11;// initialize digital pin 11, output regulating the brightness of LED
int val=0;// initialize variable va
void setup()
{
pinMode(ledpin,OUTPUT);// set digital pin 11 as “output”
Serial.begin(9600);// set baud rate at “9600”
}
void loop()
{
val=analogRead(potpin);// read the analog value of the sensor and assign it to val
Serial.println(val);// display the value of val
analogWrite(ledpin,val);// turn on the LED and set up brightness
(
maximum output value
255
)
delay(10);// wait for 0.01
Содержание Basic starter kit
Страница 1: ...1 ...
Страница 10: ...keyestudio www keyestudio cc 8 Connection for 2560 R3 ...
Страница 17: ...keyestudio www keyestudio cc 15 Connection for 2560 R3 ...
Страница 21: ...keyestudio www keyestudio cc 19 Connection for 2560 R3 ...
Страница 25: ...keyestudio www keyestudio cc 23 Connection for 2560 R3 ...
Страница 29: ...keyestudio www keyestudio cc 27 Connection for 2560 R3 ...
Страница 39: ...keyestudio www keyestudio cc 37 Connection for 2560 R3 ...
Страница 43: ...keyestudio www keyestudio cc 41 Connect the sensor to analog pin 0 Connection for R3 Connection for 2560 R3 ...
Страница 62: ...keyestudio www keyestudio cc 60 Connection for 2560 R3 ...
Страница 66: ...keyestudio www keyestudio cc 64 Connection for 2560 R3 ...
Страница 77: ...keyestudio www keyestudio cc 75 Manual for LED segment display ...
Страница 78: ...keyestudio www keyestudio cc 76 Connection for R3 Connection for 2560 R3 ...
Страница 90: ...keyestudio www keyestudio cc 88 Connection for 2560 R3 ...
Страница 94: ...keyestudio www keyestudio cc 92 ...
Страница 95: ...keyestudio www keyestudio cc 93 Connection for R3 Connection for 2560 R3 ...