Ece Ed 1
Ece Ed 1
Exercise 1 – Blink
1. To blink the LED with an Arduino for 1 sec ‘on’ time and 2 seconds ‘off’ time
(both, on breadboard and using Tinkercad)
Hardware/Software Required
• Arduino Board
• Tinkercad Software tool (https://www.tinkercad.com/)
• Breadboard
• LED and Resistors
Circuit description
To build the circuit, attach a 100-ohm resistor to either leg of the diode. Attach the leg of the LED
connected to the flat edge of the body (the negative leg, called the cathode) to ground. Connect the
remaining leg (the positive leg, called the anode) to pin 13. Then plug your Arduino board into
your computer, start the Arduino program, and upload the code.
Tinkercad
Tinkercad is a free, online collection of software tools for 3D design, electronics, and coding
Getting Started:
1. Visit https://www.tinkercad.com/
2. Sign in through your google account (Thapar Email ID only)
3. On the Dashboard, select Circuits from the drop box and click on Create new Circuit
Code
Schematic
Tinkercad’s Snapshot
Reflections (Conclusions):
In LED the longer wire ending is Anode which is connected to a digital pin on Arduino board.
The
shorter wire ending in LED is Cathode which is connected to GND. A resistor is connected to the
LED in series to protect it. On turning on the simulation, the function digitalWrite()-one with
HIGH turns the LED on. The one with the LOW turns the LED off. The alternate running of
these
functions with definite delay time, sets the LED blinking.
Exercise 2 – PushButton
On a breadboard, connect Pushbutton to turn on the built-in LED on pin 13 i.e. when you press
the button LED should glow otherwise it should be in off state.
Hardware Required
• Arduino Board
• momentary button or switch
• 10K ohm resistor
• breadboard
• hook-up wire
Circuit description
Connect three wires to the Arduino board. The first two, red and black, connect to the two long
vertical rows on the side of the breadboard to provide access to the 5 volt supply and ground. The
third wire goes from digital pin 10 to one leg of the pushbutton. The same leg of the button connects
through a pull-down resistor (here 10 KOhms) to ground. The other leg of the button connects to
the 5 volt supply.
When the pushbutton is open (unpressed) there is no connection between the two legs of the
pushbutton, so the pin is connected to ground (through the pull-down resistor) and we read a LOW.
When the button is closed (pressed), it makes a connection between its two legs, connecting the
pin to 5 volts, so that we read a HIGH.
You can also wire this circuit the opposite way, with a pullup resistor keeping the input HIGH,
and going LOW when the button is pressed. If so, the behaviour of the sketch will be reversed,
with the LED normally on and turning off when you press the button.
If you disconnect the digital I/O pin from everything, the LED may blink erratically. This is
because the input is "floating" - that is, it will randomly return either HIGH or LOW. That's why
you need a pull-up or pull-down resistor in the circuit.
Code
Schematic
Tinkercad’s Snapshot
Reflections (Conclusions):
On stimulating, the PUSH BUTTON is pressed and the resistance connected to it, makes current
flow through LED, making it glow. When the PUSH BUTTON is released, the LED turns off
instantly. This LOW to HIGH implies pull up action and HIGH to LOW implies pull down
action.
So, the LED is controlled by the PUSH BUTTON.
Assignment Tasks
A. Using Tinkercad, change the amount of time the LED is ‘ON’ to the sum of last two
digits of your Roll Number, leaving the amount of time the LED is ‘OFF’ to 2 second.
(For example, if your Roll No. is 1019***27, the LED must be kept on for 9 second).
Code
Schematic
Tinkercad’s Snapshot
B. Using Tinkercad, hook up 5 LEDs to pins 2 through 6 (with resistors). Modify the code to
turn on each one in order and then extinguish them in order.
(HINT: hook them up one additional LED at a time and make sure the new one works
before you add the next one.)
Code
Schematic
Tinkercad’s Snapshot
C. Using Tinkercad, perform Exercise 2 i.e., Connect Pushbutton to turn on the built-in LED
on pin 13 i.e. when you press the button LED should glow otherwise it should be in off
state.
Note: Each Student must attach a snapshot of the circuit and code created by him/her
using ‘Share’ icon available on Tinkercad only.
Code
Schematic
Tinkercad’s Snapshot