Difference between revisions of "ElectroBlocks/C2/Servo-Motor/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border="1" |- || '''Visual Cue''' || '''Narration''' |- || '''Slide 1''' || Welcome to the '''Spoken Tutorial''' on '''Servo Motor '''using '''Electroblocks'''. |- style="b...")
 
 
Line 6: Line 6:
 
|| '''Slide 1'''
 
|| '''Slide 1'''
 
|| Welcome to the '''Spoken Tutorial''' on '''Servo Motor '''using '''Electroblocks'''.
 
|| Welcome to the '''Spoken Tutorial''' on '''Servo Motor '''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 to create a''' Servo motor '''experiment</div>
+
* Build a set of blocks to create a''' Servo motor '''experiment
* <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 requirement'''
 
'''System requirement'''
 
|| To record this tutorial, I am using
 
|| To record this tutorial, I am using
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Ubuntu Linux OS version 22.04'''</div>
+
* '''Ubuntu Linux OS version 22.04'''
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Google Chrome Browser'''</div>
+
* '''Google Chrome Browser'''
  
 
A working internet connection to use the Electroblocks.  
 
A working internet connection to use the Electroblocks.  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| '''Slide 4:'''
 
|| '''Slide 4:'''
  
Line 29: Line 29:
  
 
|| 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 using the '''Chrome''' browser.
 
|| Let us open the''' ElectroBlocks''' website using 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;"
+
|-  
 
|| '''Show Circuit Diagram.png'''
 
|| '''Show Circuit Diagram.png'''
  
Line 48: Line 48:
  
 
Let us build this circuit using''' ElectroBlocks'''.
 
Let us build this circuit using''' ElectroBlocks'''.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| '''Slide:5'''
 
|| '''Slide:5'''
  
 
Required section
 
Required section
  
* <div style="margin-left:1.27cm;margin-right:0cm;">Logic</div>
+
* Logic
* <div style="margin-left:1.27cm;margin-right:0cm;">Button </div>
+
* Button  
* <div style="margin-left:1.27cm;margin-right:0cm;">Variables</div>
+
* Variables
* <div style="margin-left:1.27cm;margin-right:0cm;">Loops</div>
+
* Loops
* <div style="margin-left:1.27cm;margin-right:0cm;">Servo</div>
+
* Servo
* <div style="margin-left:1.27cm;margin-right:0cm;">Time</div>
+
* Time
  
 
|| We will need the following sections for this experiment.
 
|| We will need the following sections for this experiment.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
||  
 
||  
 
|| Switch back to the '''Electroblocks''' interface.
 
|| Switch back to the '''Electroblocks''' interface.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| '''Keep the loop block in the middle area (compulsory)'''
 
|| '''Keep the loop block in the middle area (compulsory)'''
  
Line 77: Line 77:
 
Drag and place it inside the '''loop''' block.
 
Drag and place it inside the '''loop''' block.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Click the '''Sensors''' section and point to lis
 
|| Click the '''Sensors''' section and point to lis
  
Line 89: Line 89:
  
 
Note that by default the button is connected to '''pin 2''' of the '''Arduino'''.
 
Note that by default the button is connected to '''pin 2''' of the '''Arduino'''.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Select the '''button is pressed''' block and Place this block in the '''if''' section of the '''if-then''' block
 
|| Select the '''button is pressed''' block and Place this block in the '''if''' section of the '''if-then''' block
 
|| Go to the '''Button section.'''
 
|| Go to the '''Button section.'''
  
 
Drag and place the''' button is pressed''' block in the '''if''' section of the '''if-then''' block.
 
Drag and place the''' button is pressed''' block in the '''if''' section of the '''if-then''' block.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Only narration  
 
|| Only narration  
  
Line 103: Line 103:
 
Drag and place this block in the then section of the if then block.
 
Drag and place this block in the then section of the if then block.
  
|| <div style="color:#000000;">Click on the <span style="background-color:transparent;">'''Loops'''</span> section.</div>
+
|| Click on the '''Loops''' section.
  
 
Drag and place the '''loop with '''block in the '''then''' section of '''if then''' block.
 
Drag and place the '''loop with '''block in the '''then''' section of '''if then''' block.
Line 115: Line 115:
 
This loop setup runs from 40 to 140, incrementing the '''I '''variable by 10 each time.
 
This loop setup runs from 40 to 140, incrementing the '''I '''variable by 10 each time.
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Only narration
 
|| Only narration
  
Line 126: Line 126:
  
 
Drag and place the '''Rotate servo''' block in the '''do''' section of the''' loop with '''block.
 
Drag and place the '''Rotate servo''' block in the '''do''' section of the''' loop with '''block.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Only narration
 
|| Only narration
  
Line 145: Line 145:
  
 
Click on the dropdown arrow in the '''Rotate servo''' block and change the pin number to pin 5 .
 
Click on the dropdown arrow in the '''Rotate servo''' block and change the pin number to pin 5 .
 +
 
Now, all the blocks appear in normal condition, with the updated circuit diagram.
 
Now, all the blocks appear in normal condition, with the updated circuit diagram.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Point to rotate servo number block  
 
|| Point to rotate servo number block  
  
Line 154: Line 155:
  
 
For that we need to use a variable '''i''' which we defined in the '''loop with '''block.
 
For that we need to use a variable '''i''' which we defined in the '''loop with '''block.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Remove the Rotate Servo number block
 
|| Remove the Rotate Servo number block
  
Line 166: Line 167:
 
|| First, delete the '''degrees''' block value by selecting the block and press the delete key.
 
|| First, delete the '''degrees''' block value by selecting the block and press the delete key.
  
Click on the '''Variable section''' and Select the '''i block'''.
+
Click on the '''Variable section''' and select the '''i block'''.
  
 
Place the '''i''' '''block''' next to the degrees section of the '''Rotate servo block.'''
 
Place the '''i''' '''block''' next to the degrees section of the '''Rotate servo block.'''
Line 173: Line 174:
  
 
Now the servo motor rotates from 40° to 140° when the push button is pressed.
 
Now the servo motor rotates from 40° to 140° when the push button is pressed.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
||  
+
|| Click on the '''Time''' section
 
+
Click on the '''Time''' section
+
  
 
drag and drop the '''Wait for 0.2 seconds '''block and place it below the '''Rotate servo '''block.
 
drag and drop the '''Wait for 0.2 seconds '''block and place it below the '''Rotate servo '''block.
Line 184: Line 183:
  
 
Drag and drop the '''Wait for 0.2 seconds''' block and place it below the''' Rotate servo''' block.
 
Drag and drop the '''Wait for 0.2 seconds''' block and place it below the''' Rotate servo''' block.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Only narration
 
|| Only narration
  
Line 205: Line 204:
  
 
Now we have created the blocks required for this experiment.
 
Now we have created the blocks required for this experiment.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Only Narration.
 
|| Only Narration.
  
Line 218: Line 217:
  
 
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.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| Point to simulation window.
 
|| Point to simulation window.
 
 
|| When the push button is pressed, the servo motor rotates from 40 to 140 degrees.
 
|| When the push button is pressed, the servo motor rotates from 40 to 140 degrees.
  
Line 226: Line 224:
  
 
Notice that once it reaches 140-degrees, it will start to rotate in the reverse direction.
 
Notice that once it reaches 140-degrees, it will start to rotate in the reverse direction.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
||  
 
||  
 
|| 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:5'''
 
|| '''Slide:5'''
  
Line 236: Line 234:
  
 
Let us summarize.
 
Let us summarize.
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| '''Slide:6'''
 
|| '''Slide:6'''
  
Line 243: Line 241:
 
|| As an assignment, please do the following
 
|| As an assignment, please do the following
  
* <div style="margin-left:1.27cm;margin-right:0cm;">Change the parameters to rotate the servo motor from 0° to 180° and rotate back to 0°. </div>
+
* Change the parameters to rotate the servo motor from 0° to 180° and rotate back to 0°.  
  
|- style="border:1pt solid #000000;padding:0.176cm;"
+
|-  
 
|| '''Slide 7:'''
 
|| '''Slide 7:'''
  

Latest revision as of 13:05, 11 October 2025

Visual Cue Narration
Slide 1 Welcome to the Spoken Tutorial on Servo Motor using Electroblocks.
Slide 2:

Learning Objectives

In this tutorial, we will learn to,
  • Build a set of blocks to create a Servo motor experiment
  • Check the output of the experiment using the simulator
Slide 3:

System requirement

To record this tutorial, I am using
  • Ubuntu Linux OS version 22.04
  • Google Chrome Browser

A working internet connection to use the Electroblocks.

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 using the Chrome browser.
Only narration Let us open a new blank project.
Show Circuit Diagram.png

Point to the servo motor and then to the button

This is the circuit diagram of servo motor experiment.

The servo motor will rotate in a specified angle when the button is pressed.

Let us build this circuit using ElectroBlocks.

Slide:5

Required section

  • Logic
  • Button
  • Variables
  • Loops
  • Servo
  • Time
We will need the following sections for this experiment.
Switch back to the Electroblocks interface.
Keep the loop block in the middle area (compulsory)

Click on the Logic sectionDrag and drop the block in working area

Place the if-then block in the loop section.

Click on the Logic section.

Select the if-then block.

Drag and place it inside the loop block.

Click the Sensors section and point to lis

Select the Button setup block and drag it in the working area.

Point to pin 2

Click on the Sensors section and select the Button.

Select the Button setup block and drag it to the working area.

Note that by default the button is connected to pin 2 of the Arduino.

Select the button is pressed block and Place this block in the if section of the if-then block Go to the Button section.

Drag and place the button is pressed block in the if section of the if-then block.

Only narration

Click on the Loops option.

Click on the loop with i block

Drag and place this block in the then section of the if then block.

Click on the Loops section.

Drag and place the loop with block in the then section of if then block.

The loop with block creates a loop with a from value, to value and increment value.

Let us change the from value as 40 and to value as 140.

By default the increment value is 1. Let us change to 10.

This loop setup runs from 40 to 140, incrementing the I variable by 10 each time.

Only narration

Click on the Add-ons option

Click on the Servo option.

Next we will add a servo motor block.

Click on the Add-ons section and click on the Servo.

Drag and place the Rotate servo block in the do section of the loop with block.

Only narration

Point to servo and push button block

Click on the dropdown arrow in the Rotate servo block and change the pin number to pin 5

Point to the blocks and the circuit diagram

You will see both the Rotate servo and button setup block will turn to grey.

Also, you will not see a circuit in the simulation screen.

This is an error.

It occurs because both the servo motor and push button are connected to pin 2 of the Arduino.

To resolve this error, we will assign a different pin number to the servo motor.

Click on the dropdown arrow in the Rotate servo block and change the pin number to pin 5 .

Now, all the blocks appear in normal condition, with the updated circuit diagram.

Point to rotate servo number block We can see the default degree as 50 which indicates the servo motor rotates to 50 degrees.

Let us set the limit between 40 to 140 degrees.

For that we need to use a variable i which we defined in the loop with block.

Remove the Rotate Servo number block

Click on the Variable option on the left-hand side of the screen.

Select the i block and drag it into the working area.

Place the i block inside the Rotate Servo block.

Only narration

First, delete the degrees block value by selecting the block and press the delete key.

Click on the Variable section and select the i block.

Place the i block next to the degrees section of the Rotate servo block.

It sets the variable i for the loop with block to work.

Now the servo motor rotates from 40° to 140° when the push button is pressed.

Click on the Time section

drag and drop the Wait for 0.2 seconds block and place it below the Rotate servo block.

The delay block is required to ensure the servo motor rotates smoothly.

Click on the Time section.

Drag and drop the Wait for 0.2 seconds block and place it below the Rotate servo block.

Only narration

Right click on the loop with i block.

Select the duplicate option.

Place this block below the loop with the i block.

Point to 140 to 40

We need the servo motor to rotate in the opposite direction when it reaches 140 degrees.

We will duplicate the entire loop with block and change the values from 140 to 40 degrees.

Right click on the loop with block and select the duplicate option.

Place this block below the loop with block.

Change the from and to values as 140 and 40.

Now we have created the blocks required for this experiment.

Only Narration.

Click on Code Icon.

Zoom and show the code.

We will see the arduino code generated by electroblocks.

Click on the Code icon.

The code includes self-explanatory comments for better understanding.

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

Point to simulation window. When the push button is pressed, the servo motor rotates from 40 to 140 degrees.

We can see the i value displayed above the servo motor.

Notice that once it reaches 140-degrees, it will start to rotate in the reverse direction.

The XML file of this experiment is provided in the code files for your reference.
Slide:5

Summary

This brings us to the end of this tutorial.

Let us summarize.

Slide:6

Assignment:

As an assignment, please do the following
  • Change the parameters to rotate the servo motor from 0° to 180° and rotate back to 0°.
Slide 7:

Thank you

Thank you for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat