Manual
www.nexusrobot.com Robot Kits manual
16
Led control
¾ Button module
The controller has 7 build-in buttons S1-S7. S1-S5 use analog input, S6, S7 use digital input.
To enable S6 and S7, please apply the jumpers indicated in the red circle. S6 uses Digital Pin2, S7 uses
Digital Pin3. Once these enable jumpers have been applied, Pin 2 and 3 will be occupied.
Sample code
int ledPin = 13;
int key_s6 = 2;
int val=0;
void setup()
{
pinMode(ledPin, OUTPUT); // Set Pin13 to output mode
pinMode(key_s6, INPUT); // Set Pin12 to output mode
}
void loop()
{
if(digitalRead(key_s6)==0) //
{
while(!digitalRead(key_s6));
val++;
}
if(val==1) {
digitalWrite(ledPin, HIGH); //
}
if(val==2)
{
val=0;