Difference between revisions of "ElectroBlocks/C2/Automatic-Gate-Opener/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border="1" |- || '''Visual Cue''' || '''Narration''' |- || '''Slide 1''' '''Title Slide''' || Welcome to the '''Spoken Tutorial''' on '''Automatic Gate Opener '''using '''E...")
 
(No difference)

Latest revision as of 18:04, 4 November 2025

Visual Cue Narration
Slide 1

Title Slide

Welcome to the Spoken Tutorial on Automatic Gate Opener using Electroblocks.
Slide 2:

Learning Objectives

In this tutorial, we will learn how to,
  1. Build a set of blocks to create an Automatic Gate opener
  2. Check the output of the experiment using the simulator
Slide 3:

System requirement

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

Required section

  • Logic
  • Motion
  • Servo
  • Math
  • Time
We will need the following sections for this experiment.
Show

Circuit Diagram 1 .png

Circuit Diagram 2 .png

This is the circuit diagram of Automatic Gate opener.

Here we will observe that the gate opens whenever an object is detected by the sensor.

Otherwise, the gate remains closed.Let us build this circuit using ElectroBlocks.

Type

https://electroblocks.org/

Let us open the ElectroBlocks website using Chrome browser.
Let us open a new blank project.

Click on the Logic section

Point to if-then-else block

Click on the Logic section.

Drag the if then else block and place it 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.
Point to trigger pin and echo pin Here, the trigger pin and echo pin are connected to pin 11 and pin 10 of 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.

Let us change the distance to 5 by clicking on the Distance in Centimetres box.

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.

Check the Copy All checkbox.

This will set the distance of the object from the ultrasonic sensor to 5 cm for all the 3 loops.

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 to check the distance between the sensor and the object.

Click on the logic option.

The third block represents the comparison block.

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

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 dropdown 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.

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 the value to 10.
Only narration

Click on the Add-ons option

Click on the Servo option.

Let us add a Servo motor block.

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

Select the Rotate servo block and place this block in the then section of the if then else block.

Notice the servo motor is connected to pin 2 of the arduino.

Point to rotate servo number block

Only narration

Only narration

In the Rotate Servo block, the default angle is 50.

It indicates that the servo motor rotates to 50 degrees by default.

Click on the number block and change the value to 90 degrees.

Only narration

Only narration

Click on the Time section.

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

change the time to 0.02 seconds.

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

Click on the Time section.

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

Change the time to 2 seconds.

Only narration

Right click on the rotate servo block.

Select the duplicate option.

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

We need the servo motor to stop rotating when no motion is detected.

Right click on the rotate servo block.

Select the duplicate option.

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

Click on the number block and change to 0. Click on the number block and change the value to 0 degrees.
Only narration

Right click on the wait for 2 seconds block.

Select the duplicate option

Let us add a wait block.

Duplicate the wait for 2 seconds block and place it below the Rotate servo block.

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

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.

Let us check the desired result using the simulator.
Click on Home icon on the tool bar and click on the Play button Click on the Home icon and press the Play button to start the simulation.
Point to simulation window The visual representation of the simulation shows that :

The servo motor rotates 90 degrees when the motion is detected within a 10 cm range.

We will create a situation, where the motion is detected above 10 cm range .

In the Setup Ultrasonic Sensor , change the distance to 15 by clicking on the Distance in Centimetres box.

Now, play the simulation again to see the output.

Notice that after increasing the distance, the servo motor rotates back to 0 degrees.

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

Summary

In this tutorial, we learnt about

  1. Build a set of blocks to create Automatic Gate opener
  2. Check the output of experiment using simulator
This brings us to the end of this tutorial. Let us summarise.
Slide:

Assignment:

  • Open a new blank project
  • Add an LED and connect it to pin 9
  • When motion is detected within a 20 cm range, the servo motor rotates to 90° and the LED turns ON
  • When no motion is detected, the servo motor returns to 0° and the LED turns OFF
As an assignment, please do the following
Slide :

Thank you

Thank you for joining.

Contributors and Content Editors

Nirmala Venkat