Activity 0 Blinking Led: Logic Circuit and Switching Laboratory Manual Msu-Iit
Activity 0 Blinking Led: Logic Circuit and Switching Laboratory Manual Msu-Iit
MSU-IIT
ACTIVITY 0
BLINKING LED
OBJECTIVE
This example aims to familiarize the student with the basic operation of the Arduino Uno board, and
Integrated Development Environment (IDE). By the end of the exercise, the student should be able to
know the basic functionalities of the IDE.
MATERIALS
DIRECTIONS
1. Proceed to the Arduino Folder and double-click the Arduino application to open the Arduino IDE which
is also shown below:
3. Press Ctrl + S or icon on the IDE to save your sketch (the term for a source code in Arduino).
4. Click the Verify Button (A on the fig.) to check if the sketch has no errors. At the bottom of the screen
you should see if the sketch was successfully scanned free of problems (B on the fig.). Moreover, the size
of the sketch file (C on the fig.) is also indicated on the black screen at the bottom to shows that it fits
the flash memory of the Arduino Uno.
5. Connect an LED to a 470Ω resistor. Note: that the longer leg of the LED is the positive (connected to one
end of resistor and the shorter one is the negative (connected to the ground). The other end of the
resistor should then be connected to the specified pin which is 13.
7. Next, make sure that the Arduino board’s COM port is properly identified by the IDE. To do this, connect
the board to the computer then from the IDE front panel go to Tools > Serial Port. A list of COM’s should
be there, choose the COM number associated with the microcontroller board. Note: the microcontroller
board’s COM no. is found near the name of the device’s driver in Device Manager.
8. Finally, upload the sketch made earlier into the board by clicking the icon in the IDE. The status of
the upload can be found near the bottom of the program [2].
CODE EXPLANATION
Line Code
1 Creates a function called setup. The function type is void and therefore does not return any
value after execution. This is only read once in a file execution and is required in a sketch.
2 The function pinMode() configures the specified pin which is 13 in this sample. It sets digital pin
13 as output.
3 Creates a function called loop. The function type is also void and therefore also does not return
any value after execution. This is read repeatedly in a file execution and usually where the main
program is. This is also required in a sketch.
4 The digitalWrite() function writes a high(5V) or low(0V) on a specified pin. In this case, a high
state is written on pin 13 to light the LED.
5 The delay function needs a constant or variable of how long in millisecond the delay will be.
This line prolongs for 1000 millisecond the LED at ON state.
6 Similar to line 4, pin 13 was set this time to low to turn off the LED.
7 This line is the same as line 5 and prolongs the LED at OFF state for 1 second.