0% found this document useful (0 votes)
44 views1 page

Mohamad Afiq Bin Ahmad 2017806612 EMD6M12

The document describes how to blink an LED using an Arduino board. It explains that you first need to load the Arduino IDE and blink example code. It then discusses initializing an LED pin as an output and using digitalWrite to turn the pin HIGH and LOW to blink the LED on and off. Delay commands are used to pause for one second between state changes, causing the LED to blink on and off repeatedly. An example for alternating blinks between two LED pins is also provided.

Uploaded by

Afiq Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

Mohamad Afiq Bin Ahmad 2017806612 EMD6M12

The document describes how to blink an LED using an Arduino board. It explains that you first need to load the Arduino IDE and blink example code. It then discusses initializing an LED pin as an output and using digitalWrite to turn the pin HIGH and LOW to blink the LED on and off. Delay commands are used to pause for one second between state changes, causing the LED to blink on and off repeatedly. An example for alternating blinks between two LED pins is also provided.

Uploaded by

Afiq Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

MOHAMAD AFIQ BIN AHMAD 2017806612 EMD6M12

After build the circuit plug Arduino board into the computer, start the Arduino Software
(IDE) and enter the code below. Also can load it from the menu File > Examples > 01.Basics
> Blink. The first thing to do is to initialize ledPin as an output pin with the line.
pinMode(ledPin, OUTPUT);
In the main loop, turn the LED on with the line:
digitalWrite(ledPin, HIGH);
Then turn it off with the line:
digitalWrite(ledPin, LOW);
The delay() commands tell the board to do nothing for 1000 milliseconds, or one second.
When you use the delay() command, nothing else happens for that amount of time.

Blinking LED Alternating Blinking LED


// the setup function runs once when you press // the setup function runs once when you press
reset or power the board reset or power the board

void setup() { void setup() {


pinMode(8, OUTPUT); pinMode(8, OUTPUT);
// initialize digital pin 8 as an output. pinMode(9, OUTPUT);
} // initialize digital pin 8 and digital pin 9 as the
// the loop function runs over and over again output.
forever }
// the loop function runs over and over again
void loop() { forever

digitalWrite(8, HIGH); void loop() {


// turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second digitalWrite(8, LOW);
// turn the LED off by making the voltage LOW
digitalWrite(8, LOW);
// turn the LED off by making the voltage LOW delay(1000);
// wait for a second
delay(1000);
// wait for a second digitalWrite(9, HIGH);
} // turn the LED on (HIGH is the voltage level)

digitalWrite(9, LOW);
// turn the LED off by making the voltage LOW

delay(1000);
// wait for a second
}

You might also like