Creating the circuit
We are done with the circuit part here
Writing the code
int myLED = 9;// This stores integer 9 in a variable named myLED
void setup()
{
//pinMode is an arduino library function which configures specific pin of arduino as i/o
//It takes in 2 inputs seperated by 'comma'
//The first input asks the pin number and second input is either INPUT or OUTPUT depending on the
//use of the input device
//In this example myLED is the pin number and the LED is acting as an OUTPUT device
pinMode(myLED, OUTPUT);
}
void loop()
{
//digitalWrite makes a pin HIGH OR LOW
// turn the LED on (HIGH is the voltage level)
digitalWrite(myLED, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
// turn the LED off by making the voltage LOW
digitalWrite(myLED, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
Following is the complete code
int myLED = 9;
void setup()
{
pinMode(myLED, OUTPUT);
}
void loop()
{
digitalWrite(myLED, HIGH);
delay(1000);
digitalWrite(myLED, LOW);
delay(1000);
}