
keyestudio
www.keyestudio.com
48
Connection for 2560 R3:
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 Code
//////////////////////////////////////////////////////////
void setup()
{
pinMode(8,OUTPUT);// set digital pin 8 as “output”
}
void loop()
{
int i;// define variable i
Summary of Contents for KS0077
Page 1: ...keyestudio www keyestudio com 1 Super Learning Kit for Arduino...
Page 14: ...keyestudio www keyestudio com 14 Connection for UNO R3 Connection for 2560 R3...
Page 32: ...keyestudio www keyestudio com 32 Connection for 2560 R3...
Page 42: ...keyestudio www keyestudio com 42 Connection for MEGA 2560...
Page 45: ...keyestudio www keyestudio com 45 Connection for UNO R3 Connection for 2560 R3...
Page 59: ...keyestudio www keyestudio com 59 Connection for 2560 R3...
Page 66: ...keyestudio www keyestudio com 66 Connection for 2560 R3...
Page 72: ...keyestudio www keyestudio com 72 Manual for LED Segment Display Connection for UNO R3...
Page 85: ...keyestudio www keyestudio com 85 8 bit Connection Method Connection for UNO R3...
Page 94: ...keyestudio www keyestudio com 94 Connection for 2560 R3 Connect the motor to digital pin 9...