lecture 1
lecture 1
ELECTRICAL SESSION-1
ID: 2006158
555 Timer
TCRT5000 IR Sensor
BJT
What is Microcontroller?
Microcontroller vs Laptop
Microcontroller has a robust interrupt system which is important for external communications and real-time
applications.
An interrupt is an external or internal event/command that interrupts the normal processing of an event and
informs the microcontroller that a device needs its service. Upon receiving the interrupt signal, the
microcontroller stops its existing program and serves the external device request.
Microcontroller vs Arduino
Development boards are PCBs that contain a particular microcontroller IC and all of the supporting
external circuitry to make the microcontroller easier to use for quick development and prototyping.
Arduino is a Microcontroller Board which is designed to use the Microchip Technology ATmega328 8-bit
Microcontroller easily
The main function of the Arduino board is to control electronics through reading inputs &
changing it into outputs
Inputs Outputs
Inputs Outputs
Flash
Memory
Digital and
Analogue I/O
pins
Types of Arduino Microcontroller
Getting Started with Arduino:
A 3.3V (100 to 150mA),5V(500mA) pin are used as power output pins(to power sensors and modules)
There are several GND pins on the Arduino, any of which can be used to ground your circuit.
What Communication Interfaces are available on Arduino UNO?
● Serial: Digital IO pins 0 and 1 are used as Serial RX and TX pins to receive and transmit
serial data.
● I2C or I2C: A4 and A5 can be configured as SDA (A4) and SCL (A5) to support I2C or I 2C
● SPI:Digital IO Pins 10, 11 12 and 13 can be configured as SPI pins SS, MOSI, MISO and
SCK respectively.
What are the Input and Output Pins of Arduino UNO?
❏ 14 pins (D0 to D13) are true digital IO pins, which can be configured using digitalWrite()
and digitalRead() functions.
❏ All these Digital IO pins are capable of sourcing or sinking 20mA of current (max 40mA ).
An additional feature of the Digital IO pins is the availability of internal pull-up resistor
❏ There are also 6 Analog Input Pins (A0 to A5)that provide a 10-bit resolution ADC feature,
which can be read using analogRead() function.(can be configured as Digital IO pins, if
required.)
❏ Digital IO pins 3, 5, 6, 9, 10 and 11 are capable of producing 8-bit PWM Signals. (use
analogWrite() function for this)
How to know whether the sensor or the electronic component works on Digital or Analog Signals?
The datasheet provides information about whether it operates on digital or analog signals. Certain sensors have the
capability to function with either digital or analog signals so it depends on how the user intends to utilize the sensor.
The Pushbutton is an example of a Digital Component whereas The Potentiometer is an example of an Analog
Component.
the next step involves determining whether the electronic component functions as an output,or as an input
Let us now talk about Digital Output and Digital Input separately!
A) Digital Output:
Example: Turning an LED on and off.
digitalWrite(pin,value) takes two arguments,
We use the function digitalRead(pin) when reading the value from a specified digital pin, either HIGH or LOW .
This function takes one parameter: pin: Arduino pin number
This function returns:HIGH or LOW
IDE
Serial monitor?
there are built-in libraries that provide basic functionality. In addition, it’s possible to
import other libraries and expand the Arduino board capabilities and features.
analogRead()
analogWrite()
digitalWrite()
Serial.begin(9600) ?? digitalRead()
analogRead()
Reads the value from the specified analog pin. Arduino boards contain a multichannel, 10-bit
analog to digital converter. This means that it will map input voltages between 0 and the
If the Analog input is 2.8 Volts, the digital value for 10-bit resolution can be calculated as follows.
Digital value = ( 2.8 / 5 ) * 1023 = 573 (Approximately)
Digital pin can only give 0,5 V output .So how we can control motor
speed or led brightness with it??
❖ The duration of "on time" is called the pulse width. To get varying analog values, you can
change pulse width
Duty Cycle
Value=(25*100)×255=0.25×255=63.75
One way is that at constant supply voltage, you might want to put a potentiometer in series with the motor to adjust
the current .The power across the resistor will just be converted into wasted heat.
Another alternative and probably the most popular among speed control methods is the pulse width modulation.If
you supply a DC motor with a 9V source and a switch but you constantly press the switch between On and Off
reduces the average voltage supply as seen by the motor thus reducing its speed.
A 90% duty cycle of the 1hz signal frequency consists of a pulse width(signal HIGH state) equal to 0.9
seconds and a signal LOW state equal to 0.1 second.
555 timer
You can just think of it as a black box with 8 pins and with the help of
external components like resistors and capacitors, it can function as
a timer, pulse generator, and oscillator depending on the values of
the externally connected components.
Two modes of operation of the 555 timer are Monostable Mode,Astable mode
For now we will discuss only Astable Mode to control the speed of the motor through pulse width
modulation.
Since the duration of output being HIGH or LOW is dependent on the charging and discharging times of the capacitor,
we can control the duty cycle of the output pulse.
TON = 0.693 * (R1 + R2) * C TOFF = 0.693 * R2 x C Period T = TON + TOFF = 0.693 * (R1 +2*R2) * C
Hence, if we replace R2 with a Potentiometer, we can control the charging and discharging tines of the capacitor and
essentially the duty cycle of the PWM Signal.
7805 Voltage Regulator:
❏ Voltage sources in a circuit may have fluctuations resulting in not providing fixed voltage therefore A
voltage regulator IC maintains the output voltage at a constant value.
❏ Here “78” means that it is a positive voltage regulator and “05” means that it provides 5V as output.
Buck converter
❏ The fixed dc input signal is changed into another dc signal at the output which is of lower
value.
❏ The efficient power conversion in bulk converter extends battery life and reduces the heat
produced.
Applications:
Many sensors ,motors used in rovers operate at lower voltages (3.3V or 5V) than the main
battery (12V or 24V).
This sensor use one wire communication protocol which only needs one digital pin to communicate with
the microcontroller.To keep the data transfer stable, you’ll also need to connect the 4.7k pull-up resistor
between the signal and power pins (Note: internal pull-ups on the arduino do not work here).
What is Pull Up Resistor?
A microcontroller in any embedded system utilizes I/O signals to communicate with the external devices.
In a 5V digital circuit, an input voltage between 2 to 5V is considered high, while a voltage between 0 to
0.8V is considered low.But, due to any reason, if the available voltage at an input pin is between 0.9 to 1.9
V, the circuit will confuse to select a high or low logic state.To avoid this floating condition, pull-up and pull-
down resistors are used.
A pull-up resistor is connected between the supply voltage and an input pin. This setup ensures the input
voltage is stable when the switch is off.
Transistor as Switch:
The Arduino’s IO pins are able to source or sink up to 40mA of current per IO pin.
Because the IO pins of the Arduino are not designed to deliver high-current to drive loads like motors or power LEDs.
Instead, we use the digital output signal from the Arduino IO pins to trigger a transistor (that works as an electronic
switch) to turn ON or OFF the high-current load device (e.g. Motor).
We just need to set (bias) the transistor properly to work as a switch (ON/OFF).
Transistors are three terminal active devices made from different semiconductor materials that can act as
either an insulator or a conductor by the application of a small signal voltage.
There are two basic types of bipolar transistor construction, PNP and NPN, which basically describes the
physical arrangement of the P-type and N-type semiconductor materials
The Bipolar Transistor basic construction consists of two PN-junctions producing three connecting
terminals (Emitter ( E ), Base ( B ) and Collector ( C )
Then bipolar transistors have the ability to operate within three different regions:
Transistor Switching ON (Saturation Region):
❏ In this region, the BJT operates as a closed switch, allowing a large current to flow from the collector to the
emitter (IC).The base-emitter & base-collector junctions are forward-biased.
❏ We apply the Vin voltage to the transistor’s base pin using any IO pin of our microcontroller (Arduino), this
base voltage will push a small current (IB) through the base of the transistor causing it to go into saturation
region (the transistor becomes like a closed switch).
❏ Consequently, the Vout will be equal to the VCEsat of the transistor (around 0.2v) which is nearly zero. Now,
the load RL (can be a motor, LED, or whatever) will have a voltage difference across its terminals. Device will
turn ON.
Transistor Switching OFF (Cut-OFF Region)
❖In this region, the BJT acts as an open switch, preventing any significant current flow from the collector to the
emitter. The base-emitter & base-collector junctions are reverse-biased.
❖ We drive the Vin voltage to the transistor’s base pin to LOW (0v) using any IO pin of our microcontroller
(Arduino), causing it to go into the cut-off region (the transistor will not conduct and becomes like an open
switch).
❖ Consequently, the Vout will be equal to the VCC which is the supply voltage of your circuit. Now, the load RL
will have no voltage difference across its terminals, and no current will flow through it because the circuit is
opened. device will turn OFF.
TCRT5000 IR Sensor
Pin Configuration:
❖ When an object is placed in front of the sensor, the IR light reflects off the object and is detected by the
phototransistor.
❖ The phototransistor conducts, pulling the sensor pin to LOW but why???
❖ A phototransistor is similar to a regular transistor but with its base exposed to light. In a phototransistor,
light hitting the base region generates electron-hole pairs, which effectively acts as the base current in
a regular transistor.
❖ In this state, the collector of the phototransistor is connected to the emitter (GND) through the
conducting phototransistor.
❖ The current flows through the phototransistor to GND, pulling the voltage at the collector (and the
Arduino input pin) down to 0V.
References:
https://www.circuitbasics.com/introduction-to-microcontrolleres/
https://lastminuteengineers.com/ds18b20-arduino-tutorial/
https://www.electrosoftcloud.com/en/arduino-pull-up-pull-down-resistors/
https://www.electronicshub.org/arduino-uno-pinout/
https://www.instructables.com/Transistors-With-Arduino-BJT-BC547-TIP120/
https://electronicscoach.com/buck-converter.html
https://randomnerdtutorials.com/555-timer-ic-tutorial/
https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
https://www.circuito.io/blog/arduino-uno-pinout/
https://besomi.com/signals-from-arduino-analog-vs-digital-pins/