Difference between revisions of "ElectroBlocks/C2/Ultrasonic-Sensor/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border="1" |- || '''Visual Cue''' || '''Narration''' |- || <div style="color:#000000;">Show Slide: </div> <div style="color:#000000;">'''Title Slide'''</div> || Welcome to...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
 
{| border="1"
 
{| border="1"
 
|-
 
|-
Line 4: Line 5:
 
|| '''Narration'''
 
|| '''Narration'''
 
|-
 
|-
|| <div style="color:#000000;">Show Slide: </div>
+
|| '''Slide 1'''
  
<div style="color:#000000;">'''Title Slide'''</div>
+
'''Title Slide'''
 
|| Welcome to the '''Spoken Tutorial''' on '''Ultrasonic Sensor''' using '''Electroblocks'''.
 
|| Welcome to the '''Spoken Tutorial''' on '''Ultrasonic Sensor''' using '''Electroblocks'''.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| '''Slide 2'''
 
|| '''Slide 2'''
  
 
'''Learning Objectives'''
 
'''Learning Objectives'''
 
|| In this tutorial, we will learn to,
 
|| In this tutorial, we will learn to,
# <div style="margin-left:1.27cm;margin-right:0cm;">Build a set of blocks for '''Ultrasonic sensor''' to detect an object in its range</div>
+
# Build a set of blocks for '''Ultrasonic sensor''' to detect an object in its range
# <div style="margin-left:1.27cm;margin-right:0cm;">Check the output of the experiment using the simulator</div>
+
# Check the output of the experiment using the simulator
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| '''Slide 3'''
 
|| '''Slide 3'''
  
 
'''System Requirements'''
 
'''System Requirements'''
  
|| To record this tutorial, I am using<span style="color:#000000;"> the following setup: </span>
+
|| To record this tutorial, I am using the following setup:  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
|| Slide 4:
+
|| '''Slide 4'''
  
 
Prerequisite
 
Prerequisite
  
 
|| To follow this tutorial,learner should have a basic knowledge of
 
|| To follow this tutorial,learner should have a basic knowledge of
* <div style="margin-left:1.27cm;margin-right:0cm;">Electroblocks </div>
+
* ElectroBlocks
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Type  
 
|| Type  
  
 
https://electroblocks.org/
 
https://electroblocks.org/
 
|| Let us open the '''ElectroBlocks''' website in the chrome browser.
 
|| Let us open the '''ElectroBlocks''' website in the chrome browser.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Only narration
 
|| Only narration
 
|| Let us open a new blank project.
 
|| Let us open a new blank project.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
|| '''Slide:5'''
+
|| '''Slide 5'''
  
Required section
+
'''Required Sections'''
* <div style="margin-left:1.27cm;margin-right:0cm;">Logic</div>
+
* <div style="margin-left:1.27cm;margin-right:0cm;">Motion</div>
+
* <div style="margin-left:1.27cm;margin-right:0cm;">LED</div>
+
* <div style="margin-left:1.27cm;margin-right:0cm;">Time</div>
+
* <div style="margin-left:1.27cm;margin-right:0cm;">Math</div>
+
  
|| We will need the following secti<span style="color:#000000;">ons f</span>or this experiment.
+
* Logic
|- style="border:1pt solid #000000;padding:0.176cm;"
+
* Motion
 +
* LED
 +
* Time
 +
* Math
 +
 
 +
|| We will need the following sections for this experiment.
 +
|-
 
||  
 
||  
 
|| Switch back to the '''Electroblocks''' interface.
 
|| Switch back to the '''Electroblocks''' interface.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Show '''Circuit Diagram.png'''
 
|| Show '''Circuit Diagram.png'''
  
Line 61: Line 63:
 
Otherwise the buzzer is turned OFF.
 
Otherwise the buzzer is turned OFF.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
||  
 
||  
 
|| Let us build this circuit using '''ElectroBlocks'''.
 
|| Let us build this circuit using '''ElectroBlocks'''.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| '''Keep the loop block in the middle area '''
 
|| '''Keep the loop block in the middle area '''
  
Line 73: Line 75:
  
 
Drag the '''if then else''' block and place inside the '''loop''' block.
 
Drag the '''if then else''' block and place inside the '''loop''' block.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Narration
 
|| Narration
  
Line 79: Line 81:
 
|| Now we will add an '''Ultrasonic sensor block.'''
 
|| Now we will add an '''Ultrasonic sensor block.'''
  
Click on the '''Sensors''' section and Click on the '''Motion'''.
+
Click on the '''Sensors''' section and click on the '''Motion'''.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Select the '''Setup Ultrasonic Sensor '''block and drag it in the working area.
 
|| Select the '''Setup Ultrasonic Sensor '''block and drag it in the working area.
  
Line 87: Line 89:
  
 
The '''Setup Ultrasonic Sensor '''block is used to configure the '''Ultrasonic sensor '''in the circuit.  
 
The '''Setup Ultrasonic Sensor '''block is used to configure the '''Ultrasonic sensor '''in the circuit.  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Point toward trigger pin and echo pin.
 
|| Point toward trigger pin and echo pin.
  
Line 94: Line 96:
 
Point towards echo pin  
 
Point towards echo pin  
  
|| I<span style="color:#000000;">n the </span><span style="color:#000000;">'''setup'''</span><span style="color:#000000;"> </span><span style="color:#000000;">'''block, '''</span><span style="color:#000000;">the </span><span style="color:#000000;">'''trigger'''</span><span style="color:#000000;"> pin and </span><span style="color:#000000;">'''echo'''</span><span style="color:#000000;"> pin are used for distance measurement.</span>
+
|| In the '''setup block''', the '''trigger''' pin and '''echo''' pin are used for distance measurement.
  
<div style="color:#000000;">'''Trigger''' pin emits ultrasonic sound waves.</div>
+
'''Trigger''' pin emits ultrasonic sound waves.
  
<div style="color:#000000;">'''Echo''' pin receives the ultrasonic waves reflected from any object in its range.</div>
+
'''Echo''' pin receives the ultrasonic waves reflected from any object in its range.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Point to '''trigger''' pin and '''echo''' pin
 
|| Point to '''trigger''' pin and '''echo''' pin
  
|| Here, the '''trigger''' pin and '''echo''' pin are connected to '''pin 11 and 10 '''of the Arduino.
+
|| Here, the '''trigger''' pin and '''echo''' pin are connected to '''pin 11'' and '''10 ''' of the Arduino.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Only narration
 
|| Only narration
  
Line 112: Line 114:
  
 
Point to the red rectangular box in front of the sensor.
 
Point to the red rectangular box in front of the sensor.
|| We can change the distance by clicking on the '''Distance in Centimetre''' box.
+
|| We can change the distance by clicking on the '''Distance in Centimetres''' box.
  
 
Click on the box and change the value to '''5.'''
 
Click on the box and change the value to '''5.'''
Line 120: Line 122:
 
This setting will set the distance of the object to 5 centimeters for all the 3 loops.
 
This setting will set the distance of the object to 5 centimeters for all the 3 loops.
  
In the simulation window, the '''5''' cm distance is displayed on the ultrasonic sensor.
+
In the simulation window, the 5 cm distance is displayed on the ultrasonic sensor.
  
 
Here the object is shown as a red rectangular box in front of the sensor.
 
Here the object is shown as a red rectangular box in front of the sensor.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Only narration
 
|| Only narration
  
Line 131: Line 133:
  
 
Place the block in the '''if '''section of''' if then else block.'''
 
Place the block in the '''if '''section of''' if then else block.'''
|| We need a '''comparison''' block.
+
|| We need a comparison block.
  
 
Click on the '''logic''' section.
 
Click on the '''logic''' section.
Line 140: Line 142:
  
 
This will compare the distance value of the object from the sensor.
 
This will compare the distance value of the object from the sensor.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Only narration
 
|| Only narration
  
Line 150: Line 152:
  
 
Click on the dropdown option and select '''less than''' '''equal to''' option from the list.
 
Click on the dropdown option and select '''less than''' '''equal to''' option from the list.
|| Let us add a '''distance '''block'''.'''
+
|| Let us add a '''distance '''block'''.  
  
 
Click on the '''Motion'''.
 
Click on the '''Motion'''.
Line 156: Line 158:
 
Drag the '''distance(cm)''' block and place this block in the '''first section '''of the '''comparison''' block.
 
Drag the '''distance(cm)''' block and place this block in the '''first section '''of the '''comparison''' block.
  
Click on the dropdown option and select '''less than equal to '''option from the list.
+
Click on the drop down option and select '''less than equal to '''option from the list.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| click on the '''math''' option available on the left side on the screen.
 
|| click on the '''math''' option available on the left side on the screen.
  
|| Next,<span style="color:#ff0000;"> </span>click on the '''Math''' section.
+
|| Next, click on the '''Math''' section.
  
 
We will add the distance value.
 
We will add the distance value.
  
Drag and place the first '''number''' '''block''' next to the '''less than equal to '''option.
+
Drag and place the first '''number block''' next to the '''less than equal to '''option.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Click on the '''number''' block and change to 10.
 
|| Click on the '''number''' block and change to 10.
 
|| Click on the '''number''' block and change to 10.
 
|| Click on the '''number''' block and change to 10.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
||  
 
||  
  
Line 182: Line 184:
 
Drag and drop the '''Turn Passive buzzer''' block to the '''then''' section of the '''if then else''' block.
 
Drag and drop the '''Turn Passive buzzer''' block to the '''then''' section of the '''if then else''' block.
  
By default the '''Buzzer '''is '''ON '''and connected to pin 9 of the '''arduino.'''
+
By default the '''Buzzer '''is '''ON '''and connected to pin 9 of the '''arduino'''.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
|| Right Click on the''' Turn a LED '''block and select the duplicate option.
+
|| Right Click on the''' Turn a LED '''block and select the '''Duplicate''' option.
  
 
Place this new block in the '''else''' section of the '''If then else''' block.
 
Place this new block in the '''else''' section of the '''If then else''' block.
  
 
Click on the dropdown option in the''' Turn Passive LED '''block''' '''and select the "'''Off'''" state.
 
Click on the dropdown option in the''' Turn Passive LED '''block''' '''and select the "'''Off'''" state.
|| Right click on the''' Turn Passive buzzer '''block and select the duplicate option.
+
|| Right click on the''' Turn Passive buzzer '''block and select the '''Duplicate''' option.
  
 
Place this new block in the '''else''' section of the '''If then else''' block.
 
Place this new block in the '''else''' section of the '''If then else''' block.
  
Change the state of the Buzzer to '''OFF''' from the dropdown option.
+
Change the state of the Buzzer to '''OFF''' from the drop down option.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Click on the '''Code''' icon to view the auto-generated Arduino code for the experiment.
 
|| Click on the '''Code''' icon to view the auto-generated Arduino code for the experiment.
  
Line 202: Line 204:
  
 
The code includes self-explanatory''' comments''' for better understanding.
 
The code includes self-explanatory''' comments''' for better understanding.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Click the '''Home''' icon and press the '''Play button''' to start the simulation.
 
|| Click the '''Home''' icon and press the '''Play button''' to start the simulation.
  
Line 213: Line 215:
 
We can see the '''Buzzer''' is turned ON.
 
We can see the '''Buzzer''' is turned ON.
  
In the block we have specified the distance as 5cms and the range is less than 10 which is true.
+
In the block we have specified the distance as 5 centimeters and the range is less than 10 which is true.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Only narration
 
|| Only narration
  
Line 230: Line 232:
 
In the '''Setup Ultrasonic sensor''' block, change the distance to 20 Centimeters.
 
In the '''Setup Ultrasonic sensor''' block, change the distance to 20 Centimeters.
  
In the simulation window, note that the object has <span style="color:#000000;">moved</span> to 20cms.
+
In the simulation window, note that the object has moved to 20cms.
  
 
Let us simulate and see the output again.
 
Let us simulate and see the output again.
Line 236: Line 238:
 
Drag the box above the play button to the start position.
 
Drag the box above the play button to the start position.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Click on the play button
 
|| Click on the play button
  
Line 243: Line 245:
 
|| Click on the '''Play''' button to see the output.
 
|| Click on the '''Play''' button to see the output.
  
Notice that the '''Buzzer '''remains in OFF state as the distance is above 10cms.
+
Notice that the '''Buzzer '''remains in OFF state as the distance is above 10 cms.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
 
|| Narration only
 
|| Narration only
 
|| The '''XML '''file of this experiment is provided in the code files for your reference.
 
|| The '''XML '''file of this experiment is provided in the code files for your reference.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-
|| '''Slide 6:'''
+
|| '''Slide 6 '''
  
 
'''Summary'''
 
'''Summary'''
  
 
In this tutorial, we learnt about,
 
In this tutorial, we learnt about,
# <div style="margin-left:1.27cm;margin-right:0cm;">Build a set of blocks for Ultrasonic sensor to detect an object in its range</div>
+
# Build a set of blocks for Ultrasonic sensor to detect an object in its range
# <div style="margin-left:1.27cm;margin-right:0cm;">Check the output of experiment using simulator</div>
+
# Check the output of experiment using simulator
  
|| This brings us to the end of this tutorial. Let us summarise.
+
|| This brings us to the end of this tutorial.  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
 
|| '''Slide 7 :'''
+
Let us summarise.
 +
|-
 +
|| '''Slide 7 '''
  
 
'''Assignment''':
 
'''Assignment''':
* <div style="margin-left:1.27cm;margin-right:0cm;">Turn '''ON the Buzzer '''when the ultrasonic sensor detects a distance equals to 10 cm.</div>
+
* Turn '''ON the Buzzer '''when the ultrasonic sensor detects a distance equals to 10 cm.
* <div style="margin-left:1.27cm;margin-right:0cm;">Turn '''OFF the Buzzer '''if it is not 10 cms.</div>
+
* Turn '''OFF the Buzzer '''if it is not 10 cm.
 +
 
 +
|| As an assignment, please do the following.
 +
|-
 +
|| '''Slide 8'''
  
|| As an assignment, please do the following
+
''' Thank You'''
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|| '''Slide 8: Thank You'''
+
 
|| Thank you for joining.
 
|| Thank you for joining.
 
|-
 
|-
 
|}
 
|}

Latest revision as of 16:08, 21 October 2025

Visual Cue Narration
Slide 1

Title Slide

Welcome to the Spoken Tutorial on Ultrasonic Sensor using Electroblocks.
Slide 2

Learning Objectives

In this tutorial, we will learn to,
  1. Build a set of blocks for Ultrasonic sensor to detect an object in its range
  2. Check the output of the experiment using the simulator
Slide 3

System Requirements

To record this tutorial, I am using the following setup:
Slide 4

Prerequisite

To follow this tutorial,learner should have a basic knowledge of
  • ElectroBlocks
Type

https://electroblocks.org/

Let us open the ElectroBlocks website in the chrome browser.
Only narration Let us open a new blank project.
Slide 5

Required Sections

  • Logic
  • Motion
  • LED
  • Time
  • Math
We will need the following sections for this experiment.
Switch back to the Electroblocks interface.
Show Circuit Diagram.png This is the circuit diagram of an ultrasonic sensor experiment.

Here, when an object comes in the defined range of the sensor the buzzer is turned ON.

Otherwise the buzzer is turned OFF.

Let us build this circuit using ElectroBlocks.
Keep the loop block in the middle area

Click on the Logic section

Point to if-then-else block

Click on the Logic section.

Drag the if then else block and place inside the loop block.

Narration

Click on the Sensors section

Now we will add an Ultrasonic sensor block.

Click on the Sensors section and click on the Motion.

Select the Setup Ultrasonic Sensor block and drag it in the working area.

Point to the Setup Ultrasonic Sensor block.

Select the Setup Ultrasonic Sensor block and drag it to the working area.

The Setup Ultrasonic Sensor block is used to configure the Ultrasonic sensor in the circuit.

Point toward trigger pin and echo pin.

Point toward trigger pin

Point towards echo pin

In the setup block, the trigger pin and echo pin are used for distance measurement.

Trigger pin emits ultrasonic sound waves.

Echo pin receives the ultrasonic waves reflected from any object in its range.

Point to trigger pin and echo pin Here, the trigger' pin and echo pin are connected to pin 11 and 10 of the Arduino.
Only narration

Point towards the number box Click on the number box and change it to 5.

Point to simulation window

Point to the red rectangular box in front of the sensor.

We can change the distance by clicking on the Distance in Centimetres box.

Click on the box and change the value to 5.

Check the Copy All checkbox.

This setting will set the distance of the object to 5 centimeters for all the 3 loops.

In the simulation window, the 5 cm distance is displayed on the ultrasonic sensor.

Here the object is shown as a red rectangular box in front of the sensor.

Only narration

Click on the logic option

Select the (=) block and drag in the working area.

Place the block in the if section of if then else block.

We need a comparison block.

Click on the logic section.

The third block represents the comparison block.

Drag the comparison block and place it in the if section of the if then else block.

This will compare the distance value of the object from the sensor.

Only narration

Click on the Motion,select distance (cm) block.

Place this block in the first section of the logic block.

Point to dropdown option

Click on the dropdown option and select less than equal to option from the list.

Let us add a distance block.

Click on the Motion.

Drag the distance(cm) block and place this block in the first section of the comparison block.

Click on the drop down option and select less than equal to option from the list.

click on the math option available on the left side on the screen. Next, click on the Math section.

We will add the distance value.

Drag and place the first number block next to the less than equal to option.

Click on the number block and change to 10. Click on the number block and change to 10.

Click on the LED option.

Select the Turn a LED block.

Place the block in the ‘then’ section of the if then else block.

Next let us add a Buzzer to the circuit.

Click on the Add-ons and click on the Passive Buzzer.

Drag and drop the Turn Passive buzzer block to the then section of the if then else block.

By default the Buzzer is ON and connected to pin 9 of the arduino.

Right Click on the Turn a LED block and select the Duplicate option.

Place this new block in the else section of the If then else block.

Click on the dropdown option in the Turn Passive LED block and select the "Off" state.

Right click on the Turn Passive buzzer block and select the Duplicate option.

Place this new block in the else section of the If then else block.

Change the state of the Buzzer to OFF from the drop down option.

Click on the Code icon to view the auto-generated Arduino code for the experiment.

Highlight the code on right side

Click on the Code icon to view the automatically generated Arduino code.

The code includes self-explanatory comments for better understanding.

Click the Home icon and press the Play button to start the simulation.

Zoom and show the simulation area

Highlight hand symbol and pressed word

Click on the Home icon and press the Play button to start the simulation.

We can see the Buzzer is turned ON.

In the block we have specified the distance as 5 centimeters and the range is less than 10 which is true.

Only narration

Point towards Setup Ultrasonic sensor block.

Point towards Distance in the Centimeter box.

Click on the box and change the value to 20

Point towards the simulation window.

Point to square box.drag this square box to the start point of the simulation.

Let us change the distance value and check the simulation output.

In the Setup Ultrasonic sensor block, change the distance to 20 Centimeters.

In the simulation window, note that the object has moved to 20cms.

Let us simulate and see the output again.

Drag the box above the play button to the start position.

Click on the play button

Point to OFF state

Click on the Play button to see the output.

Notice that the Buzzer remains in OFF state as the distance is above 10 cms.

Narration only The XML file of this experiment is provided in the code files for your reference.
Slide 6

Summary

In this tutorial, we learnt about,

  1. Build a set of blocks for Ultrasonic sensor to detect an object in its range
  2. Check the output of experiment using simulator
This brings us to the end of this tutorial.

Let us summarise.

Slide 7

Assignment:

  • Turn ON the Buzzer when the ultrasonic sensor detects a distance equals to 10 cm.
  • Turn OFF the Buzzer if it is not 10 cm.
As an assignment, please do the following.
Slide 8

Thank You

Thank you for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat