ECE Lab 2
ECE Lab 2
[Semester, Year]
17.10.2023
2
Objective:
The main objectives of the laboratory work are to learn how to use the Arduino Uno
microcontroller for basic tasks. Relying on instructions and sources provided by the professor, we
gained familiarity with programming Arduino boards and working with circuits of resistors and
LEDs.
Part 1:
In this part of the lab work, three schematics of the circuits were drawn, using tinkercad
simulations. The circuits from the Laboratory slides were used in these exercises: “Motor”, “Hello
World”, and “Wheels”.
1.
2.
3.
Part 2:
Introduction:
This part of the laboratory work was conducted experimentally in the class, using the kit
provided by the instructor and the Arduino Uno. The kit included resistors, LEDs, switches, and
wires.
The purpose of this laboratory work was to experimentally learn how the Arduino Uno
microcontroller works in simple circuits, conducting different operations that depend on tasks the
user requires.
Project 1
For the first interactive experiment, Arduino was only the source of power for the simple
circuits of a resistor, an LED, and a switch.
Task 1
3
To obtain a power in the board, one end of the first wire was connected to the 5 volts pin
on the Arduino, and the other end was plugged in the long bus line in the breadboard. The other
wire was connected to the ground on the Arduino. The switch of the circuit was placed across the
center. By its color code, the resistor of 220 ohm was found and connected to the circuit,
according to the instructions. As soon as the anode and the cathode were connected to the LED,
the USB cable was plugged into the Arduino. Pressing the switch, the results shown in the Figure 1
was witnessed.
Task 2
The second task was to place components in series – one after another. Altering the circuit
built in the first task, the second switch was placed next to the one in the circuit. Wires were
placed in series, as pictured in the illustrations. The anode and the cathode were connected to the
LED, according to the instructions. To turn the LED on, both switched had to be pressed, as they
were set in series. The result from the Figure 2 was obtained.
Task 3
In the third task, the switches were supposed to be connected in parallel. This time, the
switches were wired to the resistor. The other ends of the switched were connected to the LED.
This way, if either button is pressed, the circuit will be completed, and the light will turn on, as
shown in Figure 3.
4
Project 2
In order to accomplish this project, we also needed to use the code. Arduino has two main
functions which are setup() and loop(). Here is the code with appropriate comments:
int switchState = 0;
// switchState variable is used to store the state of switch of integer data type
void setup()
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
5
void loop()
// this function check for voltage on the inputs, and turns outputs on and off
switchState = digitalRead(2);
if(switchState==LOW)
// the button is not pressed, hence 3 (green LED) is on, whereas other 4 and 5 (blue LEDs)
are off
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
else
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(250);
// this is needed for the LEDs to turn on one-by-one, and their time delay is equal to
quarter second
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250);
}
6
Conclusion
In conclusion, as a result of done laboratory work, we can assume that members of our
group had successfully accomplished the goals. We learned the principles of creating electrical
circuits consisting of resistors, diods and switches in combination with Arduino plate. Also, we
figured out a basics of writing code for Arduino circuits. Nevertheless, during the experimental
work we had faced few problems. One of them was related to the malfunctioning of wires and
diods used, because of this we could not reach an expected result. However, we could derive a
cause of problem and successfully finished all experimental tasks.