// Welcome to: KongBot.Com - Arduino code for ( NANO )
// Intro to Arduino programming : Using the Arduino NANO with Russell
// Note #0: Connecting & Uploading go to: Tools / Board (NANO)/ ... Tools / Port (Com?) make sure correct Com port (USB) is connected
// Note #00: Learn or look up info go to : Help / Reference
// Note #1: using these " // " is only for Humans & lets you make notes to read but Arduino ignores them
// Note #2: the setup function runs once when you press reset or power the board or plug in the USB connector .....
// Note #3: an LED ( L_ight E_mitting D_iode ) is light with a + and - pin ( the longer pin is + )

int bdelay1 = 10000; // this is the delay time
int val = 0;

void setup() {
// initialize digital pins
pinMode(3, INPUT);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);

digitalWrite(3, HIGH); // writes HIGH (+5v to pin 3 ) This keeps the pin always HIGH until button is press that makes it got ( LOW or zero volts )
digitalWrite(2, LOW); // writes LOW to pin 2, 4, & 5 just to make sure they start out ( LOW or zero volts )
digitalWrite(4, LOW);
digitalWrite(5, LOW);

}

// Note #4: the loop function runs over and over again forever in the barckets { } ................................
void loop() {

val = digitalRead(3); // read the input pin

if (val == LOW)
{
digitalWrite(2, HIGH); // turns on LED when button is pressed
delay(bdelay1); // starts count down delay 10,000 = 10 seconds


digitalWrite(2, LOW); // turns off LED when button is pressed

digitalWrite(4, HIGH); // turns on digital relay ( 12 volt to go )
digitalWrite(5, HIGH); // turns on LED to show relay is on
delay (5000);
}
digitalWrite(3, HIGH); // writes HIGH (+5v to pin 3 ) This keeps the pin always HIGH until button is pres ( LOW or zero volts )
digitalWrite(2, LOW); // turn the LED at pin #2 off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED at pin #4 off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED at pin #5 off by making the voltage LOW

}