
keyestudio
www.keyestudio.cc
48
Connect the controller board, shield, breadboard and USB cable according to Arduino tutorial.
Connect the LED to digital pin 8, ball switch to analog pin 5.
Experiment principle
When one end of the switch is below horizontal position, the switch is on. The voltage of the analog
port is about 5V (1023 in binary). The LED will be on. When the other end of the switch is
below horizontal position, the switch is off. The voltage of the analog port is about 0V (0 in binary).
The LED will be off. In the program, we determine whether the switch is on or off according to the
voltage value of the analog port, whether it's above 2.5V (512 in binary) or not.
Sample Program
//////////////////////////////////////////////////////////
void setup()
{
pinMode(8,OUTPUT);// set digital pin 8 as “output”
}
void loop()
{
Содержание 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 ...