You are on page 1of 44

STEMROBO

Program Based Learning Kit Manual


PBL KIT
INDEX

S.No Experiment Page


Number
1. Introduction to Program Based Learning Kit 2
(PBL).
2. GUI based LED Pattern & Running Light. 10

3. GUI based RGB LED Programming. 14

4. GUI based LCD programming. 17

5. GUI based Pushbutton & Buzzer programming. 20

6. GUI based Seven Segment Display 23


Programming.
7. GUI based multiplexing of Seven Segment 27
Display .
8. GUI based interfacing of LDR sensor module. 32

9. GUI based IR sensor programming. 37

10. GUI based interfacing of motor driver module. 40

1 www.stemrobo.com
Activity-1

Aim: Introduction to Program Based Learning Kit (PBL).


Use & Need of PBL kit

PBL kit is a Project based learning kit. In the PBL kit there are some Input
and Output devices are connected which can be controlled by Arduino.
Arduino contains a micro controller which controls the working of these input
output devices.

 Project based learning kit can be programmed through Graphical User


Interface & Arduino IDE Electronics Explorer kit hardware configuration
allows user to start with individual modules and step by step progress
to interface multiple sensors and other components.
 Beginners can start with GUI and can move to advanced level using
Arduino IDE. Drag and drop graphical programming environment
provides a quick way to learn programming, This kit is perfect for
learning STEM and gives a head start in creative programming that will
have a positive impact on all aspects of education.
 Electronics explorer kit circuits are user friendly with easy wiring and
no soldering required. We've the designed the kit to be simple and safe
so user can learn without any risk of getting hurt. Our kit includes a full
set of tools for building, module interface, connecting wires and frame
sets.
 Instruction manuals and helpful tutorial videos are available, it will help
you to start programming and building immediately. Electronics
Explorer kit is widely accepted in various innovation labs and
technology training centers. Electronics Explorer kit transforms the
students to learner to innovator, innovator to inventor.

2 www.stemrobo.com
Electronic Explorer Kit Components:

1. STEMROBO Advanced Multi


Utility Interfacing Shield
This shield contains pin setup to connect
different input output devices directly to
this shield. This shield can directly
attached to the Arduino board by which
we can operate different modules
connected on PBL.

2. 3x3 LED Matrix Module

 LED Stands for "Light-Emitting


Diode." An LED is an electronic device
that emits light when an electrical
current is passed through it. It is
available in several different colors,
including red, green, and blue.
 A LED matrix or LED display is a
large, low resolution form of dot
matrix display useful for both
industrial and commercial information
display as well as for hobbyist
projects.
 Applications: Clock displays, Flash
lights, Indicator lights

3 www.stemrobo.com
3. Seven Segment Display Module
A seven segment display is the most basic
electronic display device that can display digits
from 0-9. They find wide application in devices
that display numeric information like digital
clocks, radio, microwave ovens, electronic
meters etc. The name 7 segment comes from
the fact that the display has 7 separate LED
segments.
It is of two types.
 Common Anode.
 Common Cathode
Applications:
 Counters
 It is used in traffic lights
 Used in Digital clocks
 Used in Timer, Lift.

4. RGB LED
RGB is a special kind of LED. There are total 4 pins,
one pin for each color respectively and last one is
common pin. The RGB led is an additive color model
in which the primary colors red, green and blue light
are added together in a single package.
RGB is of two types:
 Common Anode: Common Leg
Positive.
 Common Cathode: Common Leg
Negative.
Applications:
 For lightning different color
combination.
 Indicating of the charging status devices like Laptop, Phones
etc.

4 www.stemrobo.com
5. LCD Module
Liquid crystal display(LCD) is one of
the device which can be easily
interfaced with Arduino for
displaying the Arduino. There are
two types: graphical and character
LCD. Also based upon the size of
the LCD, there are different types:
 16x2 character LCD(16
columns and 2 rows)
 20x4 character LCD(20
columns and 4 rows)

The 16x2 LCD has a total of 16 pins out of which eight of the pins are data lines
(pins 7-14), two are for power and ground (pins 1 and 16), three are used to
control the operation of LCD (pins 4-6), and one is used to adjust the LCD screen
brightness (pin 3). The remaining two pins (15 and 16) power the backlight.

Applications:

 Display data in devices.

6. Buzzer
A buzzer or beeper is an audio signaling device
which may be mechanical, electromechanical or
piezoelectric .Typical uses of buzzers and
beepers include alarm devices, timers and
confirmation of user input such as a mouse click
or keystroke.
Applications:
 Alarm Devices
 Door bells
 Computers
 Timers

5 www.stemrobo.com
7. Ultrasonic Sensor
Ultrasonic sensor generates high
frequency sound waves and evaluates
the echo which is received back by the
sensor, measuring the time interval
between sending the signal and
receiving the echo to determine the
distance to an object. It is useful in
automatic distance measurement in
normal and difficult environments
particularly suitable for environments
where optical sensors are unusable
such as smoke, dust and similar and it
gives very accurate, stable and can be used over large ranges.
Applications: It can be used to detect or measure the following things:
 Distance
 Level
 Diameter
 Presence
 Position

8. Light Dependent Resistor(LDR)


An LDR or light dependent resistor is also
known as photo resistor. It is a kind of resistor
whose resistance varies depending upon the
amount of light falling on its surface. When the
light falls on the resistor, its resistance changes.
These resistors are often used in many circuits
where it is required to sense the presence of
light.
Applications:
 Automated Street lamp
 Smart Wallet

6 www.stemrobo.com
9. IR Sensor
An infrared sensor is an electronic
device, that emits in order to sense
some aspects of the surroundings. An
IR sensor can measure the heat of an
object as well as detects the motion.
These types of sensors measures only
infrared radiation, rather than emitting it
that is why it is called as a passive IR
sensor.
Applications:
 For detecting obstacle.
 For distinguishing between white & black

10. Switch
Switches are really simple components. When you
press a button or flip a lever, they connect two
contacts together so that electricity can flow
through them.

Applications:
 On/Off control
 User input

7 www.stemrobo.com
11. Motor Shield
Motor driver module or motor shied is
used to run different types of motors in
which motor driving IC(L293D) is being
used. It allows you to drive two DC motor
from your Arduino board, controlling
Speed & direction of each motor.
Applications:
 Robotics
 CNC machines
 Radar System

12. MIC Module


MIC is short form of Microphone.
It is used for sound detection. Module has two
outputs:
AO, analog output, real time output voltage signal
of the microphone.
DO, Digital output, When the sound intensity
reaches a certain threshold, output high and low
signal.
Applications:
 To make noise based system.
 Noise controlled System

13. DC Motor
A motor is an electrical machine which converts electrical energy into mechanical
energy. The principle of working of motor of a DC motor is that whenever a
current carrying conductor is placed in magnetic field, it experiences a
mechanical force.

8 www.stemrobo.com
Digital pin number for interfacing modules with Arduino:

S.NO Module Arduino’s Pin Number


1. LED Matrix Digital pins: 2,3,4,5,6,7,8,9,10

2. RGB LED Digital pins:9,10,11 (B,G,R)

3. LCD Digital pins:2,3,4,5,12,13(D7,D6,D5,D4,En,Rs)

4. Switch Digital pins:12(switch2 pull down)


13(switch1 pull up)
5. Seven Segment Digital pins: (2,3,4,5,10,11,12,13) , (6,7)
Display (a,b,c,d,e,f,g,h) , (SSD select)
6. LDR Analog pin: A4

7. IR Sensor Digital pin: 12 or 13

8. Buzzer Digital pin: 2

9. Motor Shield Digital pin: (6,7: motor 1), (8,9: motor 2)

10. MIC Analog pin : A0

11. Ultrasonic Sensor Digital pin: (11:Trigger),(10:Echo),5v,GND

Note: Single digital pin is being used for multiple modules so care should
be taken while interfacing different modules at same time so that sensors
doesn’t disturbs the working of each other.

9 www.stemrobo.com
Activity-2

Aim: GUI based LED Pattern & Running Light.

LED Pattern: Pattern can be defined as manner or sequence in which group of LED
is operated. Group of LED’s are switched On & Off at same time to form different LED
patterns. Digital pin number 2 to 10 is dedicated for LED matrix.

Hardware Description: We have used 5 LED’s & we will be making a “+”


pattern.

Select
this
option

 Select LED block on the left and drag it to right side. Select the pin on which we
have connected a LED.
 Repeat above step 5 times for defining different LED’s & connect them to respective
pins.

Name of the LED Pin Number


 LED1  Pin 3
 LED2  Pin 5
 LED3  Pin 6
 LED4  Pin7
 LED5  Pin 9

10 www.stemrobo.com
Code:

1..Select forever
from Control

 Select “forever” block from control option (yellow color block)


on the left top of the screen & drag it to coding area.
 Whatever task we place in forever block it is going to get
executed again & again.
 Select setLED block from output section (blue color block) &
place it inside forever block.
 Select the name of the LED & switch it on or off according
our logic.
 Select the LED & switch it on.
 Repeat above step for all other declared LED’s.
 Upload the code & connect the desired module to respective
place on Arduino shield.

11 www.stemrobo.com
Running LED Pattern:

Hardware Description: We have used 5 LED’s. Running LED’s pattern in shape


of alphabet “L”.

Code:

 Select forever block from control block.


 Place other selected blocks inside it to repeat
that task.
 We need to switch on only one LED at time
rest of them will remain off.We need to do
this at small interval delay so that it appears
like in running way.
 We will be switching on one LED and
switching off other LED which is just before it
in the pattern.
 Delay(yellow colored block) is used for
providing small time interval.It is in milli
seconds .

12 www.stemrobo.com
Output:

Learning outcome: Students learnt about interfacing of LED matrix & how to
develop logics for making different type of patterns.

DIY Task:

1. Display all arithmetic sign i.e +,-,*,/ at interval of 1 second each.


2. Display ATL one alphabet at a time at interval of 1 second each.
3. Try various other LED patterns.

13 www.stemrobo.com
Activity-3

Aim: GUI based RGB LED Programming.

RGB LED:

These LEDs have 3 tiny LEDs of 3 primary colors (red, green, and blue) where a
terminal is common for all. Some have common positive terminal (anode) and
some have common negative terminal (cathode). When different voltage is
applied to different LEDs, they make a mixture and produce several thousands of
colors.
 Rather than having 6 leads (a cathode and anode for each LED) it has only 4 one
pin for each color, and one common pin.
 Types of RGB LED:
Common Anode: Common Leg Positive
Common Cathode: Common Leg Negative.

Digital pin number 9 to 11 is dedicated for RGB.

9-Red, 10-Green, 11-Blue

Hardware Description: We will be making different color patterns.

Select
this
option

 Select RGB LED block on the left and drag it to right side. Select the pin on which
we have connected a LED.

14 www.stemrobo.com
Color of the LED Command
 Red  00FFFF
 Blue  FF00FF
 Green  FFFF00
 Magenta  0000FF
 Yellow  00FF00
 Cyan  FF0000
 White  000000

Code:

 Select “forever” block from control option (yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 Select setcolor block from output section (blue color block) & place it inside forever
block.
 Write the Hex value in that block as mentioned in table above.
 Repeat above step for all other color patterns.

15 www.stemrobo.com
Output:

Red Blue Green

Magenta Yellow Cyan

Learning outcome: Students learnt about interfacing of RGB LED & how to make
different color patterns.

DIY Task:

1. Try different color patterns by trying Different Hex code.

16 www.stemrobo.com
Activity-4

Aim: GUI based LCD programming.

LCD: A liquid-crystal display (LCD) is a flat panel display, electronic visual display,
or video display that uses the light modulating properties of liquid. Liquid crystals do
not emit light directly. LCDs are available to display arbitrary images (as in a general-
purpose computer display) or fixed images which can be displayed or hidden, such as
preset words, digits, and 7-segment displays as in a digital clock.

It is a 16*2(16 columns & 2 rows) LCD i.e. max to max 32 characters can be
displayed on it at a time, 16 characters in each row respectively.

Digital pin number 2,3,4,5,12,13 is dedicated for LCD.

Hardware Description: 4 pins are for data, one is for enable & one is for RS.

Select
this
option

 Select LCD block on the left and drag it to right side. Select the pins on which we
have connected a LCD.

17 www.stemrobo.com
LCD Pin Pin Number(Arduino)
 RS  Pin 13
 EN  Pin 12
 D4  Pin 5
 D5  Pin4
 D6  Pin 3
 D7  Pin 2

Code:

Select
forever from
Control

 Select “forever” block from control option (yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 Select printLine block from output section (blue color block) & place it inside forever
block.
 Whatever you want to display on LCD write it in block.
 Repeat above step for whatever you want to display.
 Upload the code & connect the desired module to respective place on Arduino
shield.

18 www.stemrobo.com
Output:

Learning outcome: Students learnt about interfacing of LCD & how to print on it.

DIY Task:

1. Make a count down timer.


2. Different lines at different intervals.

19 www.stemrobo.com
Activity-5

Aim: GUI based Pushbutton & Buzzer programming.

Push button: The pushbutton is a component that connects two points in a circuit
when you press it. The example turns on the buzzer when we press the button. We can
connect our pushbutton normally in 2 ways when dealing with electronics.

 Active High
 Active Low

Buzzer: an electrical device that makes a buzzing noise and is used for signaling.

Digital pin number 12,13 is dedicated for pushbutton.

12 is Active High & 13 is Active Low

Digital pin number 2 is dedicated for buzzer

Hardware Description:

Select
these
options

 Select button & speaker block on the left and drag it to right side. Select the pin on
which we have connected a button & buzzer.

20 www.stemrobo.com
Hardware Pin Number
 Active High Pushbutton  Pin 12
 Active Low Pushbutton  Pin 13
 Buzzer  Pin 2

Code:

1..Select forever &


if block from
Control section

 Select “forever” block from control option (yellow color block) on the left top of the
screen & drag it to coding area.
 After that select “if “ block from control (yellow color block).If condition is used to
check whether button is pressed or not.
 Select buttonPressed block from input section (purple color block) & place it inside
forever block.
 Select the playNote block from output section (blue color block) & place it inside if
block i.e. if button is pressed buzzer will start buzzing & on releasing button it will
stop buzzing.
 Repeat above step for using multiple pushbuttons.
 Upload the code & connect the desired module to respective place on Arduino
shield.

21 www.stemrobo.com
Learning outcome: Students learnt about interfacing of pushbutton & buzzer.Also
learnt about how to use “if ” condition in logics.

DIY Task:

1. Interfacing both the pushbuttons at same time perform two different operations
on basis of it.

22 www.stemrobo.com
Activity-6

Aim: GUI based Seven Segment Display Programming.

Seven Segment Display: A SSD is a form of electronic display device used for
displaying decimal numerals that is an alternative to the more complex dot matrix
displays.
Seven Segment Display are widely used in digital clocks, electronic meters, basic
calculators and other electronic devices that display numerical information.
There are 2 Seven Segment Display.

Digital pin number 2,3,4,5,6,7,12,13 is dedicated for Seven


Segment Display. (6 & 7 are selection pins)

If we want to work with first (left) SSD set Pin 7 as High.

If we want to work with second (right) SSD set Pin 6 as High.

Hardware Description: 8 pins are for data, two pins are for SSD selection.

Select
this
option

 Select LED block on the left and drag it to right side. Select the pin on which we
have connected a LED.

23 www.stemrobo.com
 Repeat above step 8 times for defining different LED’s & connect them to respective
pins.

Name of the LED Segment Pin Number


 LED1  A  Pin 2
 LED2  B  Pin 3
 LED3  C  Pin 4
 LED4  D  Pin 5
 LED5  E  Pin 10
 LED6  F  Pin 11
 LED7  G  Pin 12
 LED8  H  Pin 13

Code:

1..Select forever
from Control

 Select “forever” block from control option (yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 Select pinMode from setup section (dark blue color) & define pin 7 as output. For
operating seven segments.
 Select setLED block from output section (blue color block) & place it inside forever
block.

24 www.stemrobo.com
 Select the name of the LED & switch it on or off according our logic for displaying a
number.
 Repeat above step for all other declared LED’s.
 Upload the code & connect the desired module to respective place on Arduino
shield.

Output:

Timer/Counter: Number will increase after delay of few seconds.

Hardware Description: 8 pins are for data, two pins are for SSD selection.

Select
this
option

25 www.stemrobo.com
Code:

 Select forever block from control block.


 Place other selected blocks inside it to repeat that task.
 We need to switch on few LEDs at time rest of them will remain of to display a
desired number according to number we want to display.
 Delay(yellow colored block) is used for providing small time interval.It is in milli
seconds .
 We have displayed only two numbers,Repeat above step for displaying other
numbers.

Learning outcome: Students learnt about interfacing of Seven Segment Dispaly


& how to display numbers on it.

DIY Task:

1. Make a decrement timer which decreases from 9 to 0.

26 www.stemrobo.com
Activity-7

Aim: GUI based multiplexing of Seven Segment Display.

Seven Segment Display: A SSD is a form of electronic display device used for
displaying decimal numerals that is an alternative to the more complex dot matrix
displays.
Seven Segment Display are widely used in digital clocks, electronic meters, basic
calculators and other electronic devices that display numerical information.
There are 2 Seven Segment Display.

Multiplexing is where different display devices are not turned on at the same time, but
the electronics and the persistence of vision combine to make the viewer believe the
entire display is continuously active.

Digital pin number 2,3,4,5,6,7,12,13 is dedicated for Seven


Segment Display.(6 & 7 are selection pins)

If we want to work with first SSD set Pin 7 as High.

If we want to work with second SSD set Pin 6 as High.

Hardware Description: 8 pins are for data, two pins are for SSD selection.

Select
this
option

27 www.stemrobo.com
 Select LED block on the left and drag it to right side. Select the pin on which we
have connected a LED.
 Repeat above step 8 times for defining different LED’s & connect them to respective
pins.

Name of the LED Segment Pin Number


 LED1  A  Pin 2
 LED2  B  Pin 3
 LED3  C  Pin 4
 LED4  D  Pin 5
 LED5  E  Pin 10
 LED6  F  Pin 11
 LED7  G  Pin 12
 LED8  H  Pin 13

Code: Displaying same number on both segments.

 Select “forever” block from control option(yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 Select pinMode from setup section(dark blue color) & define pin 6 & 7 as output. For
operating seven segments.

28 www.stemrobo.com
 Select setLED block from output section(blue color block) & place it inside forever
block.
 Select the name of the LED & switch it on or off according our logic for displaying a
number.
 Repeat above step for all other declared LED’s.

Output:

SSD Multiplexing: Displaying two different numbers on both the


segments.

Hardware Description: 8 pins are for data, two pins are for SSD selection.

Select
this
option

29 www.stemrobo.com
Code:

 Select forever block from control block.


 Place other selected blocks inside it to repeat that task.
 Select pinMode from setup section(dark blue color) & define pin 6 & 7 as output. For
operating seven segments.
 We need to switch on few LEDs at time rest of them will remain of to display a
desired number according to number we want to display.
 Delay(yellow colored block) is used for providing small time interval.It is in milli
seconds .If we increase the delay we can see flickering of display to overcome this
we have to set delay according to persistent of vision.
 Out of 6 & 7 only one pin will be set High & another will be set Low at a
moment to have different data displayed on both segments.If we set High
on both the pins at same time the same number will be displayed on both
the segments.

30 www.stemrobo.com
Output:

Learning outcome: Students learnt about multiplexing of SSD & displaying two
different numbers on it.

DIY Task:

1. Try making a two digit timer.

31 www.stemrobo.com
Activity-8

Aim: GUI based interfacing of LDR sensor module.

Light Dependent Resistor(LDR):LDR is a component that has a variable


resistance that changes with light intensity that falls on it. The resistance decreases as
the intensity of light increases. This allows them to be used in light sensing circuits.
Analog pin number 4 i.e. A4 is dedicated for LDR module.

Hardware Description: We have used LDR module & LCD on which we will be
displaying ADC value. As light intensity increasing reading from sensor increases as light
intensity decreases reading from sensor decreases.

 Select LCD block from the left and drag it to right side. Select the pin on which we
have connected a LCD.
 We don’t need to select any block for LDR as it will be on coding part.
 Connect LDR module & LCD module to the respective slots on the shield.

32 www.stemrobo.com
Code:

 Select pinMode block from setup(dark blue


color).Select the pin and define it as input.
 Select “forever” block from control option
(yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is
going to get executed again & again.
 Select printLine block from output(blue color).
 Select analogRead block from input option
select pin & place that block inside printLine
block.
 Select delay block from control option(yellow
color block).Add delay of few seconds at the
end.
 This will display reading from sensor on the
LCD.
.

33 www.stemrobo.com
Display message on LCD on the basis of light intensity:

Hardware Description: We have used a LDR & LCD.

Code:

Select
variable
from here

34 www.stemrobo.com
 Select pinMode block from setup(dark blue color).Select the pin and define it as
input.
 Select “forever” block from control option (yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 Declare a new variable, name it as “a”(by clicking on variable orange color block)&
store value of sensor in it by inserting analogRead block in that variable block(as
shown in the code).
 Select printLine block from output(blue color) & print variable “a” on LCD. By
selecting “a” orange color block & placing it in printLine block.
 Select if block from control section(yellow color) & use greater than operator for
setting condition i.e. if condition is true print some message on LCD else do
something else.(follow as shown in code)
 This will display reading from sensor on the LCD in the first line & in second line a
message will be displayed.

35 www.stemrobo.com
Output:

Learning outcome: Students learnt about LDR & its interfacinf & how to develop
small project on basis of it.

DIY Task:

1. Turn on & off single LED on basis of light intenisty in room.


2. Turn on & off different color LEDs on basis of light intensity.

36 www.stemrobo.com
Activity-9

Aim: GUI based IR sensor programming.

IR Sensor:
 An IR sensor is a device that detects IR radiation falling on it. An IR sensor
consists of two parts, the emitter circuit and the receiver circuit. This is
collectively known as photo-coupler.
 The emitter is an IR LED and the detector is an IR LED. The photo-diode’s
resistance and output voltage change in proportion to the IR light received. This
is the underlying working principle of the IR sensor.

Out of digital pin 12 & 13 we can use any one for taking input
from IR sensor.

Hardware Description: We will be interfacing an IR sensor & LED.LED will switch


on if IR sensor detects an obstacle in front of it else remain off.

 Select LED block on the left and drag it to right side. Select the pin on which we
have connected a LED.

37 www.stemrobo.com
Code:

 Select “pinMode” block from setup option(dark blue color), select the pin as pin 13 &
select mode as input.
 Select “forever” block from control option(yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 Select “if” block from control option(yellow color block) & inside it inside forever
loop.
 Select the equality operator(green color block) for checking the condition and place
it in if block.( as shown above)
 Select the digitalRead block from input option(violet color) & place it inside equality
block and compare it with 1.
 Value of IR sensor will be equal to 1 if an obstacle is detected else it will
be 0.
 LED will switch on if condition is true else it will remain off.

38 www.stemrobo.com
Output:

LED on IR
sensor will
get on if it
detects
something.

Learning outcome: Students learnt about interfacing of IR Sensor & how to


detect obstacle using it.

DIY Task:

1. Try switching on different LEDs when obstacle is detected & when it is not.

39 www.stemrobo.com
Activity-10

Aim: GUI based interfacing of motor driver module.

Motor driver module : Motor driver module is used to run different types of
motors in which motor driving IC(L293D) is being used.

Digital pin number 6 to 9 is dedicated for motor shield.


Pin 6 & 7 for one motor, pin 8 & 9 for another motor.

Hardware Description: We have connected a motor to the motor driver module.


There are two ways of running motors either we can use block dedicated for running
motor or we can use digitalWrite function. We will be using both methods.

Select
this
option

 Select Motor option from the left and drag it to code screen.
 Select pins in that block either as 6 & 7 or 8 & 9.

40 www.stemrobo.com
Code:

 We can change the speed of the fan by using motorSpeed block (blue color block).
 We can also change the direction of rotation of motor by interchanging the pins
define in hardware section.

41 www.stemrobo.com
Automatic fan/hand dryer: (IR sensor & Motor driver)

Hardware Description: We have used an IR sensor & Motor driver module. IR


sensor will be used for detection ,if it detects anything fan will get switched on else it
will remain off.

No block selection is required at Hardware screen we won’t be using any predefined


hardware function. So directly move to coding screen.

Code:

Select
pinMode
from
here

 Select pinMode block from setup(dark blue color).Select the pin and define it as
input & output as shown above.
 Select “forever” block from control option (yellow color block) on the left top of the
screen & drag it to coding area.
 Whatever task we place in forever block it is going to get executed again & again.
 In “if” block we will be checking the status of sensor whether anything is detected
or not(as shown in the code).
 If sensor detects something fan will get switched on by setting one pin HIGH &
other pin LOW else fan will remain off by keeping both the pins on same value.

42 www.stemrobo.com
Output:

Learning outcome: Students learnt about interfacing of motor driver with


Arduino.

DIY Task:

1. Try rotating motor in both direction in presence & absence of a obstacle.

43 www.stemrobo.com

You might also like