AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH
Faculty of Engineering
Lab Report
Experiment # 04
Experiment Title: Study of a Digital Timer using the millis() function of Arduino to avoid problems
associated with the delay () function and power measurement in different power reduction modes while
the circuit is in sleep modes.
Date of Perform: 16 March 2025 Date of Submission: 16 April 2025
Course Title: Microprocessor and Embedded Systems Lab
Course Code: EE4103 Section: H
Semester: Spring 2024-25 Degree Program: BSc in CSE/EEE
Course Teacher: Md. Ali Noor
Declaration and Statement of Authorship:
1. I/we hold a copy of this Assignment/Case Study, which can be produced if the original is lost/damaged.
2. This Assignment/Case Study is my/our original work; no part has been copied from any other student’s work
or any other source except where due acknowledgment is made.
3. No part of this Assignment/Case Study has been written for me/us by any other person except where such collaboration has
been authorized.
by the concerned teacher and is acknowledged in the assignment.
4. I/we have not previously submitted or am submitting this work for any other course/unit.
5. This work may be reproduced, communicated, compared, and archived to detect plagiarism.
6. I/we permit a copy of my/our marked work to be retained by the Faculty Member for review by any
internal/external examiners.
7. I/we understand that Plagiarism is the presentation of the work, idea, or creation of another person as though it is your
own. It is a form of cheating and is a very serious academic offense that may lead to expulsion from the University.
Plagiarized material can be drawn from, and presented in, written, graphic, and visual forms, including electronic data,
and oral presentations. Plagiarism occurs when the origin of the source is not appropriately cited.
8. I/we also understand that enabling plagiarism is the act of assisting or allowing another person to plagiarize or copy my/our
work.
* Student(s) must complete all details except the faculty use part.
** Please submit all assignments to your course teacher or the office of the concerned teacher.
Group # 07
Sl No Name ID PROGRAM SIGNATURE
1 Ahasan Habib 22-48877-3 BSc in CSE
2 Md. Limon Sheikh 22-49331-3 BSc in CSE
3 Md. Mohiminul Islam Mahi 22-48725-3 BSc in CSE
4 Mizanur Rahman Fahim 22-46504-1 BSc in EEE
5 Refat Mir 22-49279-3 BSc in CSE
6
Faculty use only
FACULTY COMMENTS
Marks Obtained
Total Marks
Table of Contents
Objectives 3
Equipment List 3
Circuit Diagram 3
Experimental Output Results (Color Photographs) 4-5
Simulation Output Results (Color Photographs) 6-9
Answers to the Questions in the Lab Manual 9-10
Discussion 11
References 11
Marking Rubrics (to be filled by Faculty):
Level Excellent Proficient Good Acceptable Unacceptable No Response
Category [5] [4] [3] [2] [1] [0]
Able to clarify the Able to clarify the
Able to clarify the
Able to clarify the understanding of the understanding of the lab
understanding of the lab Unable to clarify the
Title and understanding of the lab, lab experiment, but a experiment, but it lacks a
experiment, no issues are understanding of the
Objectives no issues are missing and few issues are few important issues of
missing but its formatting is lab experiment.
formatting is good. wrong, and its the experiment without
not good.
formatting is bad. maintaining the format.
Able to explain the
Able to explain the Presents the
Able to explain the experimental codes Presents the experimental
experimental codes and experimental codes
Codes and experimental codes and but simulation codes but didn’t explain
simulation methods using but didn’t explain
Methods simulation methods using method using simulation methods using
Proteus but is not formatted simulation methods
Proteus very well. Proteus is not Proteus clearly.
well. using Proteus.
explained well.
Key results and Major results, such as No Response/
Key results and images are Misses several key copied from
images are there. experimental and
Key results and images there. Figures/Tables have results and images. others/
Figures/Tables lack a simulation results’
are there. Figures/Tables all identifications, such as Figures/Tables lack identical
few identifications, images are not
Results have all identifications the axis labels, numbers, identification, such as the submissions
such as the axis included. Figures
and refer to them properly and captions with a few axis labels, numbers, and with gross
labels, numbers, and and tables are poorly
in the texts. minor errors; the texts refer captions; the texts don’t errors/image
captions; the texts constructed or not
them. refer them. file printed
refer them. presented.
Proper interpretation of Proper interpretation of
Interpretation of Very poor
results and summarizes results and summarizes the Misses the interpretation
results is presented. interpretation of
Discussion the results to draw a results to draw a conclusion of key results. There is
However, there is a the results. No
and conclusion, discusses its but didn’t discuss its little connection between
disconnect between connection
Conclusion applications in real-life applications in real-life the results and
the results and between results and
situations to connect with situations to connect with discussion.
discussion. discussions.
the report’s conclusion. the conclusion of the report.
Able to produce all Able to produce all Able to produce all Able to produce all Unable to produce all
Question and questions’ answers questions’ answers but questions’ answers questions’ answers but questions’ answers
Answer correctly maintaining the didn’t maintain the lab but wrong answers to wrong/missing answers and completely
lab report format. report format. a few questions. to multiple questions. wrong answers.
Total Marks
Comments
(25)
Page 2 of 11
Objectives:
The objectives of this experiment are to
a) Study the application of the millis() function, a built-in Timer of Arduino.
b) Build a digital timer to turn on several LEDs every minute sequentially on an Arduino
Microcontroller Board
c) Implement a sequential LED light pattern control system using an input switch and an
Arduino Microcontroller Board.
d) Measure the amount of power and energy saved using power down or power save mode.
Equipment List:
1. Arduino IDE (2.0.1 or any recent version)
2. Arduino Microcontroller board
3. LED lights (Red, Green, and Yellow- each 2)
4. Six 100 resistors and one 10 k resistor
5. One tilt switch
6. Jumper wires
Circuit Diagram:
Figure 1: Circuit connection diagram.
Figure 2: Experimental Setup of an LED Light Pattern Control System using a Tilde switch.
Page 3 of 11
Experimental Output Results:
Figure 3: LED is OFF Figure 4: RED and YELLOW LED is ON
Figure 5: RED, YELLOW and GREEN LED is ON. Figure 6: RED, YELLOW and 2 GREEN LED is ON
Figure 7: All the LED is ON Figure 8: LED is OFF in low power.
Page 4 of 11
Figure 9: LED is ON in low power. Figure 10: Voltage and Current flow when LED is ON in
low power.
Figure 11: LED is OFF in low power. Figure 12: Voltage and Current flow when LED is
OFF in low power.
Page 5 of 11
Simulation Output Results:
Figure 12: All the LED is OFF.
Figure 13: First LED is ON.
Page 6 of 11
Figure 14: Second LED is ON.
Figure 15: Third LED is ON.
Page 7 of 11
Figure 16: Fourth LED is ON.
Figure 17: Fifth LED is ON.
Page 8 of 11
Figure 18: Sixth LED is ON.
Answers to the Questions in the Lab Manual:
LED light pattern control system (Code)
const int SwitchPin = 8;
unsigned long PreviousTime = 0;
int SwitchState = 0;
int PrevSwitchState = 0;
int led = 2;
long interval = 60000; // for 1 min = 60,000 ms delay
void setup() {
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
pinMode(SwitchPin, INPUT);
}
void loop() {
unsigned long CurrentTime = millis();
if (CurrentTime - PreviousTime > interval) {
PreviousTime = CurrentTime;
digitalWrite(led, HIGH);
led++;
if (led == 7){
}
}
SwitchState = digitalRead(switchPin);
if (SwitchState != PrevSwitchState){
for (int x = 2 ; x < 8; x++) {
digitalWrite(x, LOW);
}
Page 9 of 11
led = 2;
PreviousTime = CurrentTime;
}
PrevSwitchState = SwitchState;
}
Power-Down Periodic Mode (Code)
#include <LowPower.h>
#define LED_RED 8
void setup() {
Serial.begin(9600);
pinMode(LED_RED, OUTPUT);
// SMCR = 0b00001101;
}
void loop() {
digitalWrite(LED_RED, HIGH);
delay(5000);
Serial.println(“Arduino:- I am going for a Nap”);
digitalWrite(LED_RED,LOW);
LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF,
TIMER0_OFF, SPI_OFF, USART0_OFF, TWI_OFF);
Serial.println(“Arduino:- Hey I just Woke up”);
delay(5000);
}
Figure 19: Output or Power down.
Page 10 of 11
Discussion:
Information about the millis() function was gathered from various sources via the internet and study
materials. The millis()function, a built-in Arduino library, was utilized to track time and control LED
progression at specified intervals. Drawbacks of the millis()function, such as challenges in achieving
precise timing, were identified through observations. Based on the insights gained, a digital timer
system was implemented using Arduino UNO, resistors, LEDs, tilt switch, and wires. The necessary
code for the timer program was developed considering the millis()function and digital timer operation.
Simulations in Tinker CAD and Proteus validated the expected outcomes. Additionally, an alternative
digital timer was created using delay durations based on student IDs, with manual observation and
evaluation of the results. Both hardware and software implementations met the experiment's
objectives, demonstrating the expected outcomes effectively.
References:
1) https://www.arduino.cc/
2) ATMega328 manual
3) https://www.avrfreaks.net/s/login/?ec=302&inst=V4&startURL=%2Fforum%2Ftut-c-
newbies-guide-avr-timers
4) https://circuitdigest.com/article/everything-you-need-to-know-about-arduino-uno-board-
hardware
5) https://developerhelp.microchip.com/xwiki/bin/view/products/mcu-mpu/8bit-
pic/peripherals/timers/timer-0/
Page 11 of 11