Beamer Arduino
Beamer Arduino
Beamer Arduino
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Innovative Experiments
Sandeep S Ghugre
UGC DAE CSR KC
Email : [email protected]
September 1, 2020
Introduction
ARDUINO Microcontroller
What is a Microcontroller
Why Arduino
Variants of Arduino
Accessories
ARDUINO Uno
Getting Started
Hardware Connection to the host computer
The Hardware Real Estate
Software
Initial Conguration
First Program
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Read Analog Voltage
ADC on ARDUINO
Using the IDE
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Multivibrator
555 Timer
Arduino & Astable Multivibrator
Sketch for recording data
Analysis of the data
Pulse Width Modulation
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Introduction
Arduino & PWM
Precaution
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Preamble
UGC-DAE Consortium for Scientic Research, Kolkata Centre, is in
the process of developing a range of innovative, low cost experiments
based on the routinely available resources for the undergraduates.
These experiments are expected to be illustrative and contribute in
their understanding of the basics of the subject, apart from rejuve-
nating the fun factor in the learning process.
These experiments utilize the
1. Sound card in the PC
2. Open source micro-controller : ARDUINO
as the Data Acquisition System.
What is a Microcontroller
Why ARDUINO
The choice of Arduino was essentially due to
1. It being an Open Source , both in terms of hardware and
software.
2. The hardware is cheap and can also be built from the
components using the information available in public domain.
3. It can be powered from either a USB or a standalone DC power
4. It can run standalone from a computer (chip is programmable)
and it has a decent memory.
5. It can communicate with the computer via
5.1 Serial , Bluetooth , Ethernet
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno What is a Microcontroller
Charging of a Capacitor Why Arduino
Time Period of Pendulum Variants of Arduino
Arduino & LDR Accessories
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
1. It can work with both Digital and Analog signals, Sensors and
Actuators
2. Various shields, ie. boards that can be plugged on top on the
Arduino or it's variants, that enhance it's capabilities are easily
available.
3. Ready made boards such as IR transmitter and receiver, Ultra
sonic distance sensor, to name a few are available which can
be easily integrated with the Arduino microcontroller, allowing
us the exibility to congure experiments as per user
requirement and specications.
Variants of ARDUINO
Mega
UNO
And at the heart of the Arduino development board is the Atmel ARV
Atmega 328 , a modied Harvard architecture 8-bit RISC single chip mi-
crocontroller which was developed by Atmel in 1996.
Accessories
To eectively use the Arduino, we require the following
1. USB printer cable : Essential
2. Breadboards
2.1 Mini Breadboard
2.2 Small Breadboard
3. Breadboard Power supply , this has to be used with a small
breadboard.
4. Connectors : Essential
5. Breakout Boards
6. Components : : As per the requirement of expt.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno What is a Microcontroller
Charging of a Capacitor Why Arduino
Time Period of Pendulum Variants of Arduino
Arduino & LDR Accessories
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Breadboards
Small Breadboard
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno What is a Microcontroller
Charging of a Capacitor Why Arduino
Time Period of Pendulum Variants of Arduino
Arduino & LDR Accessories
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Connectors
Male-to-Male Connector
9V snap Connector
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno What is a Microcontroller
Charging of a Capacitor Why Arduino
Time Period of Pendulum Variants of Arduino
Arduino & LDR Accessories
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Prototype Shield
Prototype Shield for Nano
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno Getting Started
Charging of a Capacitor The Hardware Real Estate
Time Period of Pendulum Software
Arduino & LDR Read Analog Voltage
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Uno
The Arduino UNO is based on the ATmega328P chip.
CPU
Heart of the Arduino development board is the Atmel ARV Atmega
328P (A) , 8-bit RISC single chip microcontroller which was devel-
oped by Atmel in 1996. It can be identied as a prominent black
rectangular chip with 28 pins. The components of relevance to
us are
1. 32 KB Flash memory.
2. 2KB of RAM.
3. CPU.
4. A non volatile Electrically Erasable Programmable Read Only
Memory (EEPROM).
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno Getting Started
Charging of a Capacitor The Hardware Real Estate
Time Period of Pendulum Software
Arduino & LDR Read Analog Voltage
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
These pins just measure voltage and not the current because they
have very high internal resistance. Hence, only a small amount of
current ows through these pins.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno Getting Started
Charging of a Capacitor The Hardware Real Estate
Time Period of Pendulum Software
Arduino & LDR Read Analog Voltage
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Misc.
Anatomy of a sketch
Having done this we are all set to write our rst program for the
micro-controller which is the equivalent of Hello World.
For example if we have a 10 bit ADC, then it will map Vmin to Vmax →
2 = 1024 digital numbers.
10
Arduino accepts analog signals upto 5 volt and hence has a resolution
of about 5 milli-Volt.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno Getting Started
Charging of a Capacitor The Hardware Real Estate
Time Period of Pendulum Software
Arduino & LDR Read Analog Voltage
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
analogRead(pin_number)
We know that, the ADC after converting the input analog voltage
would return an integer value (channel number).
The above command, would store the ADC channel number (as an integer) corresponding to the analog
voltage connected to Analog Pin Number 0.
SerialMonitor
Now, the value obtained would have to be displayed to the user.
A simple solution would be to use the Serial Monitor for this pur-
pose.
Serial.begin(9600)
Once the program is compiled and uploaded you can view the results
in the Serial Monitor
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno Getting Started
Charging of a Capacitor The Hardware Real Estate
Time Period of Pendulum Software
Arduino & LDR Read Analog Voltage
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Once the program is compiled and uploaded you can view the results
in the Serial Monitor , the commands of relevance are shown below.
We know that the ADC converts the input into a channel number,
and we then need to map it or convert it to the quantity of our
relevance. This is referred to as Calibration .
For example, using the on-board 10 bit ADC, we have the following
relation
0V −→ 0 channel
5V −→ 1023 channel
volt 5
=
channel 1023
5
unknown voltage = × channel
1023
We could use the inbuilt millis() function, which records the number of
milliseconds that have elapsed since the program started running.
Figure: RC circuit.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
1 i n t SensorValue = 0 ;
2 i n t l e d = 13 ; 1 }
3 f l o a t Voltage1 = 0 . 0 ; 2
4 l o n g u n s i g n e d now = 0 . 0 ; 3 void loop () {
5 long unsigned then = 0.0 ; 4 S e n s o r V a l u e = a n a l o g R e a d ( A0 ) ;
6 long unsigned elapsed = 0.0 ; 5 now = m i l l i s ( ) ;
7 6 Voltage1 = SensorValue * (
8 void setup () { 5.0/1023.0) ;
9 pinMode ( LED_BUILTIN , OUTPUT) ; 7 e l a p s e d = now − t h e n ;
10 S e r i a l . begin (9600) ; 8 // S e r i a l . p r i n t ( e l a p s e d ) ;
11 d i g i t a l W r i t e ( l e d , LOW) ; 9 // S e r i a l . p r i n t ( "\ t " ) ;
12 delay (9000) ; 10 S e r i a l . p r i n t l n ( Voltage1 ) ;
13 d i g i t a l W r i t e ( l e d , HIGH ) ; 11 }
14 then = m i l l i s () ;
On the Serial Monitor we observe the time and the voltage across
the capacitor.
1 f o r i i n r a n g e ( l e n ( x_time ) ) :
2 temp1 = 5 . 0 − y_vc [ i ]
3 y_vr . append ( temp1 )
4 temp2 = Vin −Vin * ( np . exp (( − x_time [ i ] ) / ( r * c ) ) )
5 y_vc_theo . append ( temp2 )
6 temp1 =0.0
7 temp2 =0.0
8
9 f1 . close ()
10 X=[0 , tau , 1 0 * tau , 1 0 0 * t a u ]
11 Y= [ 0 . 6 3 * Vin , 0 . 6 3 * Vin , 0 . 6 3 * Vin , 0 . 6 3 * Vin ] # f o r o b s e r v i n g t a u
12 p l t . p l o t (X , Y , " r −−" )
13 p l t . p l o t ( x_time , y_vc , " go " , l a b e l=" Expt " )
14 p l t . p l o t ( x_time , y_vc_theo , "b* " , l a b e l=" T h e o r e t i c a l " )
15 p l t . l e g e n d ( l o c=" b e s t " )
16 p l t . x l a b e l ( ' Time ( s e c o n d ) ' )
17 p l t . y l a b e l ( ' Voltage across capacitor ' )
18 p l t . x l i m ( 0 , max ( x_time ) )
19 plt . grid ()
20 p l t . show ( )
Proximity Sensor
The IR Proximity sensor is based on the principle of IR reectance.
Experimental Setup
The Sketch is identical to the one used for the charging of the capacitor.
Analysis
1 i m p o r t numpy a s np
2 import m a t p l o t l i b . pyplot as p l t
3
4 d a t a = np . g e n f r o m t x t ( " pendulum_data . t x t " )
5
6 time1 = data [ : , 0 ] / 1 0 0 0 . 0
7 v o l t a g e = data [ : , 1 ]
8
9 plt . p l o t ( time1 , v o l t a g e )
10 plt . x l a b e l ( ' Time ( s ) ' )
11 plt . y l a b e l ( ' V o l t a g e ( Arb . u n i t ) ' )
12 plt . t i t l e ( ' Measurement o f t i m e p e r i o d o f a pendulum ' )
13 plt . grid ()
14 plt . show ( )
Voltage Divider
The conguration comprises of two series resistors R & R across 1 2
These energetic electrons break free from crystal lattice and are avail-
able for conduction.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Sandeep
Figure: LDR connected in aSvoltage
Ghugre divider
Innovative(replacing
Experiments R ) and coupled
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
BJT as a Switch
Figure: Determination of h.
Determination of h
Determination of h.
1 i n t ledPin = 13; // LED c o n n e c t e d t o d i g i t a l p i n 13
2 i n t S e n s o r V a l u e =0;
3 f l o a t Voltage =0.0;
4
5 void setup () {
6 pinMode ( LED_BUILTIN , OUTPUT) ;
7 S e r i a l . begin (9600) ;
8 }
9
10 void loop () {
11 d i g i t a l W r i t e ( l e d P i n , HIGH ) ;
12 S e n s o r V a l u e=a n a l o g R e a d ( A0 ) ;
13 Voltage = SensorValue *(5.0/1023.0) ;
14 S e r i a l . p r i n t l n ( Voltage ) ;
15 delay (5000) ;
16 d i g i t a l W r i t e ( l e d P i n , LOW) ;
17 S e n s o r V a l u e=a n a l o g R e a d ( A0 ) ;
18 Voltage = SensorValue *(5.0/1023.0) ;
19 S e r i a l . p r i n t l n ( Voltage ) ;
20 delay (5000) ;
21 }
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor
Time Period of Pendulum
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Multivibrator
555 Timer
1
Frequency =
Thigh + Tlow
1.44
=
R1 + 2 × R2
× C
Thigh
Dugty Cycle =
(Thigh + Tlow )
Waveform
Ocourse, the response of the load which receives this signal is slower
than the frequency of the pulse.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor Introduction
Time Period of Pendulum Arduino & PWM
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
Thus the output voltage is a function of the duty cycle, for a 100%
duty cycle, the output, would be 5 volt, whereas a 50% duty cycle
would result in an output of 2.5 volt.
These pins can be identied as they have the symbol ∼ before the
corresponding pin numbers.
analogWrite(PWM_pin_no, level)
analogWrite (PWM_pin_no, level) function can be used to PWM
, where the parameter level is an 8 bit integer, which can be set to
obtain the desired duty cycle
voltage.
Sandeep S Ghugre Innovative Experiments
Outline
Introduction
ARDUINO Microcontroller
ARDUINO Uno
Charging of a Capacitor Introduction
Time Period of Pendulum Arduino & PWM
Arduino & LDR
Transistor as a Switch
Astable Multivibrator using 555 Timer
Pulse Width Modulation
Precaution
1 int led = 9; // t h e PWM p i n t h e LED i s a t t a c h e d t o
2 int brightness = 0; // how b r i g h t t h e LED i s
3 i n t fadeAmount = 5 ; // how many p o i n t s t o f a d e t h e LED by
4
5 // t h e s e t u p r o u t i n e r u n s once when you p r e s s r e s e t :
6 void setup () {
7 // d e c l a r e p i n 9 t o be an o u t p u t :
8 pinMode ( l e d , OUTPUT) ;
9 }
10
11 // t h e l o o p r o u t i n e r u n s o v e r and o v e r a g a i n f o r e v e r :
12 void loop () {
13 // s e t t h e b r i g h t n e s s o f p i n 9 :
14 analogWrite ( led , b r i g h t n e s s ) ;
15 // chang e t h e b r i g h t n e s s f o r n e x t t i m e t h r o u g h t h e l o o p :
16 b r i g h t n e s s = b r i g h t n e s s + fadeAmount ;
17
18 // r e v e r s e t h e d i r e c t i o n o f t h e f a d i n g a t t h e e n d s o f t h e f a d e :
19 i f ( b r i g h t n e s s <= 0 | | b r i g h t n e s s >= 2 5 5 ) {
20 fadeAmount = −fadeAmount ;
21 }
22 // w a i t f o r 30 m i l l i s e c o n d s t o s e e t h e dimming e f f e c t
23 delay (30) ;
24 }
Precautions
Before commencing any experiment, run the Blink code to ensure
the board and the communications with the host computer are well
established.
Thanks