Difference between revisions of "ElectroBlocks/C2/Control-LED-with-Push-Button/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 42: Line 42:
 
|| Let us open the''' ElectroBlocks''' website using '''Chrome''' browser.
 
|| Let us open the''' ElectroBlocks''' website using '''Chrome''' browser.
 
|-
 
|-
|| Click on the New''' File/Blank''' File option.
+
|| On the top tool bar, click on the New''' File/Blank''' File option.
  
 
A '''pop-up window''' will appear—click '''OK''' to proceed.
 
A '''pop-up window''' will appear—click '''OK''' to proceed.
Line 84: Line 84:
 
|| '''Keep the loop block in the middle area (compulsory)'''
 
|| '''Keep the loop block in the middle area (compulsory)'''
  
Click on the Logic section
+
In the left panel, click on the Logic section
  
 
Point to if-then- blockDrag and drop the block in working area
 
Point to if-then- blockDrag and drop the block in working area
Line 107: Line 107:
 
Point to '''pin 2'''
 
Point to '''pin 2'''
  
Click on the dropdown option and change the PIN 4.
+
Click on the drop down option and change the PIN 4.
|| Click on the '''Sensors''' section and select the '''Button.'''
+
|| In the left panel, click on the '''Sensors''' section and select the '''Button.'''
  
 
Next, select the '''Button setup''' block and drag it to the working area.
 
Next, select the '''Button setup''' block and drag it to the working area.
Line 135: Line 135:
 
|| Narration only  
 
|| Narration only  
  
Click on the '''Add-ons''' section and Click on the LED section
+
In the left panel, click on the '''Add-ons''' section and Click on the LED section
  
 
Select the first '''Turn a LED ON''' block and drag it in the working area.
 
Select the first '''Turn a LED ON''' block and drag it in the working area.
Line 148: Line 148:
 
Place this block in the '''then''' section of the '''if-then''' block.
 
Place this block in the '''then''' section of the '''if-then''' block.
 
|-
 
|-
|| Click on Time section
+
||In the left panel, click on Time section
  
 
Select the wait for 0.2 second block
 
Select the wait for 0.2 second block
Line 226: Line 226:
  
 
Highlight the code on right side
 
Highlight the code on right side
|| Click on the '''Code icon''' to view the automatically generated''' Arduino code'''.
+
||On the top tool bar,click on the '''Code icon''' to view the automatically generated''' Arduino code'''.
  
 
The code includes self-explanatory''' comments''' for better understanding.
 
The code includes self-explanatory''' comments''' for better understanding.
Line 235: Line 235:
  
 
Highlight hand symbol and '''pressed''' word
 
Highlight hand symbol and '''pressed''' word
|| Click the '''Home''' icon and press the '''Play button''' to start the simulation.
+
|| On the top tool bar, click the '''Home''' icon and press the '''Play button''' to start the simulation.
  
 
A '''hand symbol''' and the word '''"Pressed"''' appear near the push button.
 
A '''hand symbol''' and the word '''"Pressed"''' appear near the push button.

Revision as of 15:03, 1 October 2025

Title of the Script: Control LED with Push button

Author: Pratik Bhosale

Keywords: Electroblocks, Arduino, LED block, Time block, video tutorial.

Visual Cue Narration
Slide 1

Title Slide

Welcome to the Spoken Tutorial on Control LED with Push Button using Electroblocks.
Slide 2

Learning Objectives

In this tutorial, we will learn how to
  • Create blocks to control the LED using a Push Button
  • 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 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 Chrome browser.
On the top tool bar, click on the New File/Blank File option.

A pop-up window will appear—click OK to proceed.

Point to loop block

Click on the New File/Blank File option to create a new circuit.

Click OK in the popup window to proceed .

We can see a loop block by default.

Show Circuit Diagram.png

LED_ON.png

LED_OFF.png

Point to the push button in the circuit diagram

This is the circuit diagram of Control LED with Push Button.

If the push button is pressed, the LED turns ON and waits for one second.

If the push button is released, the LED turns OFF and waits for one second.

Let us build this circuit using ElectroBlocks.

Slide 5

Required Section

We need the various blocks from the below section for this experiment.
  • Logic
  • Button
  • LED
  • Time
Switch back to the Electroblock interface. Switch back to the Electroblock interface.
Keep the loop block in the middle area (compulsory)

In the left panel, click on the Logic section

Point to if-then- blockDrag 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 and drag it to the working area.

The if-then block is used to make decisions in your program.

Place this block inside the loop block.

Loop block repeats the program continuously in a loop.

Click the Sensors section and point to lis

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

Point to button setup block

Point to pin 2

Click on the drop down option and change the PIN 4.

In the left panel, click on the Sensors section and select the Button.

Next, select the Button setup block and drag it to the working area.

Here we will set up the parameters for the button.

By default the button is connected to pin 2 of the Arduino.

Click the pin dropdown and change it to pin 4.

Click on the Button section

select the button is pressed block.

Place this block in the if section of the if-then block

Point to pin 4 in both the blocks

Again, go to the Button section.

Select and drag the button is pressed block to the working area.

Note that pin 4 is set by default as per the button setup block.

Place this block in the if section of the if-then block.

Narration only

In the left panel, click on the Add-ons section and Click on the LED section

Select the first Turn a LED ON block and drag it in the working area.

Place this block in the then section of the if-then block.

Next we will add an LED block.

Click on the Add-ons section and then Click on LED.

Select the Turn a LED ON block and drag it to the working area.

Place this block in the then section of the if-then block.

In the left panel, click on Time section

Select the wait for 0.2 second block

Drag it in the working area.

Place this block below Turn a LED ON

Change the time to 1 second

Point to if then block

Narration only

Click the Time section.

Select the wait for 0.2 second block and drag it to the working area.

Place this block below the Turn a LED ON block.

Change the time in the wait block to 1 second.

We have set up the blocks to execute, if the button is pressed.

The LED is turned ON for 1 second.

Click on Button section

Drag and drop button is released block in the working area.

Place it inside the loop block

Next we will setup for the Blocks to Turn OFF the LED

Go to the Button section.

Select the button is released block and drag it to the working area.

Place this block below the if-then block, inside the loop blocks.

Right-click on LED block and select Duplicate option

Place this block below the button is released block

Change the LED state from ON to OFF

Now, we will need a block to turn OFF the LED.

Right-click on the LED block and select the Duplicate option.

A new LED block is generated in the working area.

Place this block below the button is released block.

Change the LED state from ON to OFF using the dropdown.

This turns the LED OFF when the button is not pressed.

Narration only

Right-click on the wait for 1 second block and select the Duplicate option.

Place this block below the Turn a LED OFF block.

Next, we will add a wait block.

Right-click on the wait for 1 second block.

Select the Duplicate option.

Place this block below the Turn a LED OFF block.

Narration only

Point to simulation area

We have completed the block creation for this experiment.

Note that the circuit is auto generated on the right side as per the created blocks.

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

Highlight the code on right side

On the top tool bar,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

On the top tool bar, click the Home icon and press the Play button to start the simulation.

A hand symbol and the word "Pressed" appear near the push button.

This indicates that the push button is currently pressed in the simulation.

When the button is pressed, the LED turns ON for 1 Second

When the button is “Released” the hand symbol disappears, and the LED turns OFF

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

Summary

  • Create blocks to control the LED using a Push Button
  • Check the output of the experiment using the simulator
This brings us to the end of this tutorial. Let us summarise.
Slide 7

Assignment

As an assignment, do the following
  • The LED should be ON continuously.
  • Whenever the push button is pressed, LED should be OFF.
Slide 8

Thank You

Thank you for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat