Lab Manual MES Experiment 1
Lab Manual MES Experiment 1
Title: Familiarization with a microcontroller, the study of blink test and implementation of a
traffic control system using microcontrollers.
Introduction:
The objective of this experiment is to get familiarized with Microcontrollers. Besides, the
specific objectives of this experiment are to-
✓ Make an LED blink using an Arduino and its delay function.
✓ Implement a traffic control system using Arduino and its delay function and LEDs.
Arduino is an open-source platform used for creating interactive electronics projects. Arduino
consists of both a programmable microcontroller and a piece of software, or IDE (Integrated
Development Environment) that runs on your computer, used to write and upload computer
code to the microcontroller board. Arduino Uno also doesn’t need a hardware circuit
(programmer/ burner) to load a new code into the board. We can easily load a code into the
board just using a USB cable and the Arduino IDE (which uses an easier version of C++ to
write code).
2. Now, write the following program on the blank sketch for the LED blink test.
void setup() {
// Pin type declaration for the red LED
pinMode(5, OUTPUT);
}
void loop() {
// Turning on the voltage at output pin 5 (for red LED)
digitalWrite(5, HIGH);
delay(1000); // LED is turned on for 1 second
digitalWrite(5, LOW);
delay(1000); // LED is turned off for 1 second
}
Anode
Cathode
(a) (b)
Fig. 3 Circuit connections for (a) LED blink test and (b) Traffic light control system
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
// Turning on the voltage at the output pin 8 (for green LED)
digitalWrite(8, HIGH);
delay(3000); // green LED is on for 3 seconds
// Turning off the voltage at output pin 8 (for green LED)
digitalWrite(8, LOW); // green LED is off
3. After writing the program you must save your code file in a folder. For this purpose, please
go to the File Menu → Save As → give a File name in the file name box (for example,
Traffic_light_control) → Select Save.
N.B. After saving your code, a sketch file with the desired file name will be stored in a
folder with the same file name.
4. Now you need to verify/compile your code to find out and correct the errors. For this, please
go to the Sketch Menu → Verify/Compile or press Ctrl+R or click on this button just
below the menu bar. If the code is correct then the code compilation done message will be
displayed, otherwise, an error message will be displayed.
5. After the compilation is done successfully, you need to upload your code onto the Arduino Uno
board. To upload the program, connect your Arduino Uno R3 board to your PC with a USB
cable. Before uploading the code, select the board type and port at your Arduino IDE. For this
purpose, please go to the Tools Menu → Board: “Arduino Uno” → Arduino Uno. Then again
go to the Tools Menu → Ports → COMx, here x means an integer number that corresponds to
the Arduino Uno board that is automatically detected by the IDE.
6. After you have selected the board and port, you must upload the code. For this, please go
to the Sketch Menu → Upload or press Ctrl+U or click on this button just below the
menu bar. If the code is correct then the code upload-done message will be displayed,
otherwise, an error message will be displayed. Based on the error message (if any), please
go to the code, and correct them. Usually, students forget to set up the Tools or select an
inappropriate board or COMx port number to get such kinds of error messages.
void setup() {
// pin connections for the LED lights
pinMode(GREEN_PIN, OUTPUT);
pinMode(YELLOW_PIN, OUTPUT);
pinMode(RED_PIN, OUTPUT);
}
void loop() {
//Turning on the voltage at output pin# 8 for the green LED
digitalWrite(GREEN_PIN, HIGH);
delay(green_on); // delays are in ms; 1 s = 1000 ms
//Turning off voltage at output pin# 8 for the green LED
digitalWrite(GREEN_PIN, LOW);
1) Include all codes and scripts in the lab report with detailed explanations according to
the report writing template given in the portal.
2) Show the output/results in the form of images. Give their captions and descriptions.
3) Include the Proteus simulation of the LED blink program and traffic light control
system. Explain the simulation methodology. You may learn the simulation from the
following video link: https://www.youtube.com/watch?v=yHB5it0s2oU
Reference(s):
1) https://www.arduino.cc/.
2) https://www.coursera.org/learn/arduino/lecture/ei4ni/1-10-first-glance-at-a-program.
3) Jeremy Blum; Exploring Arduino: Tools and Techniques for Engineering Wizardry.