Difference between revisions of "ElectroBlocks-archive-sept-2025/C2/Control-LED-with-Push-button/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 3: Line 3:
 
'''Author''': Pratik Nemane
 
'''Author''': Pratik Nemane
  
'''Keywords''': Electroblocks, arduino board, 220 ohm resistor, LEDs breadboard, Push button, video tutorial, spoken tutorial.
+
'''Keywords''': Electroblocks, arduino board, 220 ohm resistor, LEDs, breadboard, Push button, video tutorial, spoken tutorial.
  
  
{| border =1
+
 
|-  
+
{| style="border-spacing:0;"
|| '''Visual Cue'''
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Visual Cue'''
|| '''Narration'''
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Narration'''
|-  
+
 
|| '''Slide 1:'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Slide 1:'''
  
 
'''Title slide.'''
 
'''Title slide.'''
|| Welcome to the Spoken Tutorial on '''Control LED with Push button''' using '''Electroblocks'''.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Welcome to the Spoken Tutorial on '''Control LED with Push button''' using '''Electroblocks'''.
|-  
+
 
|| '''Slide 2:'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Slide 2:'''
  
 
'''Learning Objective'''
 
'''Learning Objective'''
|| In this tutorial, we will learn how to,
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we will learn how to,
 +
 
 
# Build a set of blocks to create a '''Control LED with Push button.'''
 
# Build a set of blocks to create a '''Control LED with Push button.'''
 
# Check the output of the experiment using the '''simulator.'''
 
# Check the output of the experiment using the '''simulator.'''
  
  
|-  
+
 
|| '''Slide 3:'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Slide 3:'''
  
 
'''System Requirements'''
 
'''System Requirements'''
|| To record this tutorial, I am using:
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| To record this tutorial, I am using:
 +
 
 
* Ubuntu Linux OS version 22.04
 
* Ubuntu Linux OS version 22.04
 
* Google Chrome Browser.
 
* Google Chrome Browser.
  
 
A working internet connection to use '''Electroblocks'''.  
 
A working internet connection to use '''Electroblocks'''.  
|-  
+
 
|| '''Slide 4:'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Slide 4:'''
  
 
'''Prerequisite'''
 
'''Prerequisite'''
Line 40: Line 46:
  
 
https://spoken-tutorial.org
 
https://spoken-tutorial.org
|| To follow this tutorial,  
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| To follow this tutorial,  
 +
 
 
* Learner should have a basic knowledge of '''Electroblocks interface '''
 
* Learner should have a basic knowledge of '''Electroblocks interface '''
 +
 
* If not, please visit the relevant tutorials on this website.
 
* If not, please visit the relevant tutorials on this website.
  
  
|-  
+
 
|| Open Google Chrome browser.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Open Google Chrome browser.
 +
 
  
 
In New Tab, type
 
In New Tab, type
  
 
[https://electroblocks.org/ https://electroblocks.org/] '''
 
[https://electroblocks.org/ https://electroblocks.org/] '''
 +
  
 
Point towards Default Blink LED circuit.
 
Point towards Default Blink LED circuit.
|| Let us open the '''Electroblocks''' platform using '''Google''' '''Chrome''' browser.  
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Let us open the '''Electroblocks''' platform using '''Google''' '''Chrome''' browser.  
 +
 
  
 
For that Type this url in the address bar.
 
For that Type this url in the address bar.
 +
  
 
You will see the default '''Blink LED''' circuit on the screen.
 
You will see the default '''Blink LED''' circuit on the screen.
|-  
+
 
|| Click on the '''New File/Blank File''' icon.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the '''New File/Blank File''' icon.
 +
 
  
 
A Pop-up window appears.
 
A Pop-up window appears.
 +
  
 
Click on the '''OK''' button.
 
Click on the '''OK''' button.
|| Click on the '''New File/Blank file''' option available on the toolbar.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the '''New File/Blank file''' option available on the toolbar.
 +
 
  
 
A pop-up window appears on the screen.
 
A pop-up window appears on the screen.
 +
  
 
Click on the '''OK''' button to start a new project.
 
Click on the '''OK''' button to start a new project.
|-  
+
 
|| Point towards the '''loop block'''.
+
|-
|| A default '''loop block''' appears on the screen.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point towards the '''loop block'''.
 +
 
 +
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| A default '''loop block''' appears on the screen.
 +
 
  
 
Let’s drag the default '''loop block''' to a convenient place to insert '''push buttons.'''
 
Let’s drag the default '''loop block''' to a convenient place to insert '''push buttons.'''
  
|-  
+
 
|| '''Add the entire Output video.mp4 in the main video at the 1:29 timestamp.'''
+
 
|| We will create this '''Control LED with Push Button''' output.
+
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Add the entire Output video.mp4 in the main video at the 1:29 timestamp.'''
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| We will create this '''Control LED with Push Button''' output.
 +
 
  
 
Let’s get started by building a '''Control LED '''with '''Push Button''' using '''Electroblocks'''.
 
Let’s get started by building a '''Control LED '''with '''Push Button''' using '''Electroblocks'''.
|-  
+
 
|| '''Main Video.mp4'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Main Video.mp4'''
 +
 
  
 
Click on '''Logic Block.'''
 
Click on '''Logic Block.'''
 +
  
 
Point towards all the six '''Logic Blocks'''.
 
Point towards all the six '''Logic Blocks'''.
 +
  
 
Select''' If then else block, '''and drag it in the working area.''' '''
 
Select''' If then else block, '''and drag it in the working area.''' '''
 +
  
 
Place this block inside the '''loop block'''.
 
Place this block inside the '''loop block'''.
|| First we need an '''If then else''' block.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| First we need an '''If then else''' block.
 +
 
  
 
Click on the '''Logic''' option on the left panel.
 
Click on the '''Logic''' option on the left panel.
Line 97: Line 130:
 
You can see six '''Logic Blocks'''.
 
You can see six '''Logic Blocks'''.
  
Click on the '''If then else block''' and drag it to the working area.
 
  
Place this '''block''' inside the '''loop block'''.
+
Click on the '''If then else block''' and place it inside the '''loop block'''.
|-  
+
 
|| Click on '''Sensor'''  
+
 
 +
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on '''Sensor'''  
 +
 
  
 
A new list will appear.  
 
A new list will appear.  
 +
  
 
Click on the '''Button''' option.
 
Click on the '''Button''' option.
|| We require a '''button''' to control the '''LED'''.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| We require a '''button''' to control the '''LED'''.
 +
 
  
 
Click on the '''Sensors''' menu on the left panel.
 
Click on the '''Sensors''' menu on the left panel.
 +
  
 
A new list opens.
 
A new list opens.
 +
  
 
Click on the '''Button''' option.
 
Click on the '''Button''' option.
|-  
+
 
|| Point the cursor towards all three blocks.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point the cursor towards all three blocks.
 +
 
  
 
Select the '''Button setup''' block and drag it in the working area.
 
Select the '''Button setup''' block and drag it in the working area.
 +
  
 
Point towards “'''Button Setup'''”
 
Point towards “'''Button Setup'''”
|| You will see three blocks.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| You will see three blocks.
 +
 
  
 
Select the '''Button setup''' block and drag it to the working area.
 
Select the '''Button setup''' block and drag it to the working area.
 +
  
 
The '''Button Setup block''' is used to configure a '''push button''' in the '''circuit'''.  
 
The '''Button Setup block''' is used to configure a '''push button''' in the '''circuit'''.  
|-  
+
 
|| Point towards '''“Connected to PIN#”'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point towards '''“Connected to PIN#”'''
 +
 
  
 
Point towards the '''“USE PULL UP Resistor” '''checkbox.
 
Point towards the '''“USE PULL UP Resistor” '''checkbox.
 +
  
 
Point towards the unchecked checkbox.
 
Point towards the unchecked checkbox.
 +
  
 
Only narration.
 
Only narration.
|| By default, this button is connected to '''pin 2''' of Arduino.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| By default, this button is connected to '''pin 2''' of Arduino.
 +
 
  
 
Below, you can see the '''"USE PULLUP Resistor"''' checkbox.
 
Below, you can see the '''"USE PULLUP Resistor"''' checkbox.
  
By default this box is unchecked.
+
 
 +
By default this box is unchecked.  
 +
 
  
 
We will leave the box unchecked.
 
We will leave the box unchecked.
 +
  
 
This indicates that an '''external resistor''' is connected to the '''button'''.
 
This indicates that an '''external resistor''' is connected to the '''button'''.
|-  
+
 
|| Point the cursor to the “Is Button Pressed” checkbox.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point the cursor to the “Is Button Pressed” checkbox.
 +
 
  
 
Show the enabled checkbox.
 
Show the enabled checkbox.
|| By default, the '''"Is Button Pressed"''' checkbox in the button setup is always checked.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| By default, the '''"Is Button Pressed"''' checkbox in the button setup is always checked.
  
 
It means that the '''button''' will be in the pressed state when you run the simulation.
 
It means that the '''button''' will be in the pressed state when you run the simulation.
|-  
+
 
|| Point towards the '''“Loop Dropdown”'''
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point towards the '''“Loop Dropdown”'''
 +
 
  
 
Point towards
 
Point towards
|| Observe the '''loop dropdown''' option in the '''Button Setup''' block.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Observe the '''loop dropdown''' option in the '''Button Setup''' block.
 +
 
  
 
Here, '''loop 1''' is selected.  
 
Here, '''loop 1''' is selected.  
  
It indicates that this setting is applied to '''loop 1 only'''.
+
 
|-  
+
It indicates that this setting is applied to '''loop 1''' only.
|| Point to '''Copy All''' option.
+
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point to '''Copy All''' option.
 +
 
  
 
Check the '''Copy All''' checkbox.
 
Check the '''Copy All''' checkbox.
 +
  
 
Point to button setup block
 
Point to button setup block
|| You can see a checkbox against the '''Copy all''' option in the '''Button setup''' block.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| You can see a checkbox against the '''Copy all''' option in the '''Button setup''' block.
  
 
Check the '''Copy All''' checkbox.
 
Check the '''Copy All''' checkbox.
  
 
This setting ensures that the '''button''' setup stays the same, for all the loops in the simulation.
 
This setting ensures that the '''button''' setup stays the same, for all the loops in the simulation.
|-  
+
 
|| Only narration
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration
 +
 
  
 
Click on the '''Button''' option.
 
Click on the '''Button''' option.
 +
  
 
Select the '''Button is pressed?''' block and drag it in the working area.
 
Select the '''Button is pressed?''' block and drag it in the working area.
 +
  
 
Place this block in the '''If '''section of the '''if then else '''block.
 
Place this block in the '''If '''section of the '''if then else '''block.
|| We will add a '''button''' '''block''' in the '''loop'''.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| We will add a '''button''' '''block''' in the '''loop'''.
 +
 
  
 
Click on the '''Button''' option.
 
Click on the '''Button''' option.
  
Select the '''Button is pressed?''' block and drag it to the working area.
+
 
 +
Select the '''Button is pressed?''' block.  
 +
 
  
 
Place this block in the '''If '''section of the '''if then else '''block.
 
Place this block in the '''If '''section of the '''if then else '''block.
|-  
+
 
|| Only narration.
+
 
 +
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration.
 +
 
  
 
Click on '''Add-ons.'''
 
Click on '''Add-ons.'''
 +
  
 
A new list will appear.
 
A new list will appear.
|| Now we will add an '''LED''' to the circuit.
+
 
 +
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Now we will add an '''LED''' to the circuit.
 +
 
  
 
Click on the '''Add-ons''' menu on the left panel.
 
Click on the '''Add-ons''' menu on the left panel.
 +
  
 
A new list appears.  
 
A new list appears.  
|-  
+
 
|| Click on the LED option.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the LED option.
  
  
 
Point to the two blocks.
 
Point to the two blocks.
 +
  
 
Click on the '''Turn on LED''' block and drag it in the working area.
 
Click on the '''Turn on LED''' block and drag it in the working area.
|| Click on the '''LED''' option.  
+
 
 +
 
 +
Place this block in the '''then''' section of the '''If then else '''block.
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the '''LED''' option.  
  
 
You will see that two LED blocks will appear.
 
You will see that two LED blocks will appear.
  
Click on the '''Turn on LED''' block and drag it to the working area.
 
|-
 
|| Place this block in the '''then''' section of the '''If then else '''block.
 
  
Point to the grey area.
+
Click on the '''Turn on LED''' block
 +
 
 +
 
 +
Place this block in the '''then''' section of the '''If then else '''block.
 +
 
 +
 
 +
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point to the grey area.
 +
 
  
 
Point to the simulation screen to show the circuit disappeared.
 
Point to the simulation screen to show the circuit disappeared.
|| Place this block in the '''then''' section of the '''If then else '''block.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| You will see that the '''LED''' and '''button setup''' block will turn to grey.
  
You will see that the '''LED''' and '''button setup''' block will turn to grey.
 
  
 
Also, the circuit in the '''simulation '''is not seen'''.'''
 
Also, the circuit in the '''simulation '''is not seen'''.'''
|-  
+
 
|| Point towards the LED and push button.
+
|-
|| This is an error.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point towards the LED and push button.
 +
 
 +
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| This is an error.
 +
 
  
 
It occurs because both the '''LED''' and '''push button''' are connected to '''pin 2''' of the arduino.
 
It occurs because both the '''LED''' and '''push button''' are connected to '''pin 2''' of the arduino.
 +
  
 
To resolve this error, we will assign a different '''pin number''' to the '''LED'''.
 
To resolve this error, we will assign a different '''pin number''' to the '''LED'''.
  
|-  
+
 
|| Click on the dropdown arrow in the LED block.
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the dropdown arrow in the LED block.
 +
 
  
 
Change the pin number to '''pin 4'''.
 
Change the pin number to '''pin 4'''.
 +
  
 
Point towards the block to show their changes.
 
Point towards the block to show their changes.
|| Click on the dropdown arrow in the '''LED block'''.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the dropdown arrow in the '''LED block'''.
 +
 
  
 
Change the pin number to '''pin 4'''.
 
Change the pin number to '''pin 4'''.
 +
  
 
Now, all the blocks appear in normal condition.
 
Now, all the blocks appear in normal condition.
  
|-  
+
 
|| Only narration.
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration.
 +
 
  
 
Only narration
 
Only narration
 +
  
 
Click on the '''Time''' section.
 
Click on the '''Time''' section.
|| Let’s make sure that the LED remains turned '''ON '''for a sufficient amount of time.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Let’s make sure that the LED remains turned '''ON '''for a sufficient amount of time.
 +
 
  
 
For this, we must add a '''delay''' '''block'''.
 
For this, we must add a '''delay''' '''block'''.
 +
  
 
Click on '''Time''' on the left panel.
 
Click on '''Time''' on the left panel.
|-  
+
 
|| Drag and drop the '''Wait block for 0.2 second''' block in the working area.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Drag and drop the '''Wait block for 0.2 second''' block in the working area.
 +
 
 +
 
 
Place this block below the '''turn ON LED''' block.
 
Place this block below the '''turn ON LED''' block.
  
Change the time to 2 seconds in the block.
 
  
|| Drag and drop the '''Wait block for 0.2 second''' block to the working area.
+
HaChange the time to 2 seconds in the block.
 +
 
 +
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Drag and drop the '''Wait block for 0.2 second''' block to the working area.
 +
 
  
 
Place this block below the '''turn ON LED block'''  
 
Place this block below the '''turn ON LED block'''  
 +
  
 
Change the time to 2 seconds in the '''block'''.
 
Change the time to 2 seconds in the '''block'''.
  
|-  
+
 
|| Only narration.
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration.
 +
 
  
 
Right click on the '''Turn on LED''' '''block''' and select the '''Duplicate''' option.
 
Right click on the '''Turn on LED''' '''block''' and select the '''Duplicate''' option.
  
|| Now we will '''turn OFF the LED.'''
+
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Now we will turn '''OFF '''the '''LED.'''
 +
 
  
 
Right click on the '''Turn on LED''' '''block''' and select the '''Duplicate''' option.
 
Right click on the '''Turn on LED''' '''block''' and select the '''Duplicate''' option.
 +
  
 
A new '''Turn on LED block''' will be created in the working space.
 
A new '''Turn on LED block''' will be created in the working space.
  
|-  
+
 
|| Drag and place this new block inside the '''else''' section of '''If then else''' block.
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Drag and place this new block inside the '''else''' section of '''If then else''' block.
 +
 
  
 
Click on the dropdown arrow and select '''OFF'''
 
Click on the dropdown arrow and select '''OFF'''
  
|| Drag and place this new '''block''' inside the '''else''' section of '''If then else''' block.
 
  
To change the state of the LED, click on the dropdown arrow and select '''OFF'''.
+
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Drag and place this new '''block''' inside the '''else''' section of '''If then else''' block.
 +
 
 +
 
 +
Change the state to OFF.
 +
 
  
 
This '''block''' '''turns OFF''' the LED connected to '''pin 4'''.
 
This '''block''' '''turns OFF''' the LED connected to '''pin 4'''.
|-  
+
 
|| Only narration.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration.
 +
 
  
 
Click on the '''Code Icon'''.
 
Click on the '''Code Icon'''.
|| Now we will see the '''arduino code''' generated by '''electroblocks'''.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Now we will see the '''arduino code''' generated by '''electroblocks'''.
 +
 
  
 
Click on the '''Code Icon'''.
 
Click on the '''Code Icon'''.
|-  
+
 
|| Highlight '''Pin 4''' line of code.
+
|-
|| In the '''void setup''' function, you will see '''pin 2''' and '''pin 4''' are mentioned.  
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Highlight '''Pin 4''' line of code.
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| In the '''void setup''' function, you will see '''pin 2''' and '''pin 4''' are mentioned.  
 +
 
  
 
'''Pin 4''' is assigned to the '''LED'''.
 
'''Pin 4''' is assigned to the '''LED'''.
|-  
+
 
|| Point to OUTPUT
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point to OUTPUT
 +
 
  
 
Highlight '''Pin 2''' line of code.
 
Highlight '''Pin 2''' line of code.
  
|| It is termed as '''OUTPUT''' because the '''arduino''' gives a value to the '''LED'''.
+
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| It is termed as '''OUTPUT''' because the '''arduino''' gives a value to the '''LED'''.
  
  
Line 306: Line 451:
 
It is termed as '''INPUT '''because the '''arduino''' takes a value from the '''push button'''.
 
It is termed as '''INPUT '''because the '''arduino''' takes a value from the '''push button'''.
  
|-  
+
 
|| Point to the '''void loop function.'''
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Point to the '''void loop function.'''
 +
 
  
 
Highlight the '''if ((digitalRead(2) == HIGH))'''
 
Highlight the '''if ((digitalRead(2) == HIGH))'''
 +
  
 
Highlight '''LED''' turned '''HIGH''' line of code.
 
Highlight '''LED''' turned '''HIGH''' line of code.
  
|| This is the '''void loop function'''.
+
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| This is the '''void loop function'''.
 +
 
  
 
It shows the action performed by '''components''' and '''sensors''' in the experiment.
 
It shows the action performed by '''components''' and '''sensors''' in the experiment.
 +
  
 
'''if ((digitalRead(2) == HIGH))'''
 
'''if ((digitalRead(2) == HIGH))'''
  
 
This line checks if the button connected to '''pin 2''' is pressed or not.
 
This line checks if the button connected to '''pin 2''' is pressed or not.
 +
  
 
'''digitalWrite(4, HIGH)'''
 
'''digitalWrite(4, HIGH)'''
Line 325: Line 480:
 
This line describes the '''LED''' connected to '''pin 4''' '''turn ON'''.
 
This line describes the '''LED''' connected to '''pin 4''' '''turn ON'''.
  
|-  
+
 
|| Highlight '''delay(2000)''' line of code.
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Highlight '''delay(2000)''' line of code.
 +
 
  
 
Arduino narration.
 
Arduino narration.
 +
  
 
Highlight '''LED''' turned '''LOW''' line of commands.
 
Highlight '''LED''' turned '''LOW''' line of commands.
  
|| '''delay(2000)'''
+
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''delay(2000)'''
  
 
This line makes sure that the '''LED''' is '''turned ON '''for '''2 seconds'''.
 
This line makes sure that the '''LED''' is '''turned ON '''for '''2 seconds'''.
 +
  
 
In the '''arduino syntax''', '''2000 milliseconds''' represent '''2 seconds.'''
 
In the '''arduino syntax''', '''2000 milliseconds''' represent '''2 seconds.'''
Line 345: Line 508:
 
This line describes the '''LED''' connected to '''pin 4''' '''turns OFF'''.
 
This line describes the '''LED''' connected to '''pin 4''' '''turns OFF'''.
  
|-  
+
 
||  
+
 
|| Let’s check the desired result using the simulator.
+
 
|-  
+
|-
|| Click on Home page
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"|  
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Let’s check the desired result using the simulator.
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on Home page
  
  
 
Click on the play button
 
Click on the play button
|| Click on the '''Home''' page option from the toolbar.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the '''Home''' page option from the toolbar.
  
  
 
Click on the '''Play''' button to start the simulation.
 
Click on the '''Play''' button to start the simulation.
|-  
+
 
|| Show the '''LED''' is turned '''ON'''.
+
|-
|| The visual representation of the simulation shows that:
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Show the '''LED''' is turned '''ON'''.
 +
 
 +
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| The visual representation of the simulation shows that:
  
 
When the '''push button''' is pressed, the '''LED''' is '''turned ON '''for 2 seconds.
 
When the '''push button''' is pressed, the '''LED''' is '''turned ON '''for 2 seconds.
 +
  
 
Let us check the output of the '''LED''' if we don’t press the '''pushbutton'''.
 
Let us check the output of the '''LED''' if we don’t press the '''pushbutton'''.
|-  
+
 
|| Only narration
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration
 +
 
  
 
'''Uncheck''' the Is button is pressed box in the button setup
 
'''Uncheck''' the Is button is pressed box in the button setup
 +
  
 
Click on the '''play''' button again.
 
Click on the '''play''' button again.
  
|| For this condition, '''uncheck''' the '''Is button pressed''' checkbox in the button '''setup block'''.
+
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| For this condition, '''uncheck''' the '''Is button pressed''' checkbox in the button '''setup block'''.
 +
 
  
 
Start the simulation again.
 
Start the simulation again.
 +
  
 
Notice that when the push button is '''not pressed''', the '''LED remains OFF'''.
 
Notice that when the push button is '''not pressed''', the '''LED remains OFF'''.
  
|-  
+
 
|| Only narration.
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Only narration.
 +
 
  
 
'''check''' the '''Is button pressed '''box in the '''button setup block.'''
 
'''check''' the '''Is button pressed '''box in the '''button setup block.'''
 +
  
 
Click on the '''Previous Step''' button to return to the beginning of Step 1.
 
Click on the '''Previous Step''' button to return to the beginning of Step 1.
|| To see the simulation in the step by step manner.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| To see the simulation in the step by step manner.
 +
 
  
 
First '''check''' the '''Is button pressed '''box in the '''button setup block.'''
 
First '''check''' the '''Is button pressed '''box in the '''button setup block.'''
 +
  
 
Then click on the '''Previous Step''' button to return to the beginning of '''Step 1'''.
 
Then click on the '''Previous Step''' button to return to the beginning of '''Step 1'''.
  
|-  
+
 
|| Click on the '''Next step'''
+
 
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the '''Next step'''
 +
 
  
 
Point the cursor to the yellow colour outline
 
Point the cursor to the yellow colour outline
  
|| Click on the '''Next Step''' button and notice the blocks in the working area.
+
 
 +
 
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Click on the '''Next Step''' button and notice the blocks in the working area.
 +
 
  
 
The '''execution state''' of the '''block''' is highlighted with a '''yellow''' colour '''outline'''.  
 
The '''execution state''' of the '''block''' is highlighted with a '''yellow''' colour '''outline'''.  
|-  
+
 
|| '''Add the entire Output video.mp4 in the main video at the 10:21 timestamp.'''
+
|-
|| Notice the output of the experiment.
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Add the entire Output video.mp4 in the main video at the 10:21 timestamp.'''
|-  
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Notice the output of the experiment.
||  
+
 
|| This brings us to the end of this tutorial.
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"|  
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| This brings us to the end of this tutorial.
  
  
 
Let us summarise.
 
Let us summarise.
|-  
+
 
|| Slide 5:  
+
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Slide 5:  
  
 
'''Summary'''
 
'''Summary'''
|| In this tutorial, we will learnt how to,
+
 
 +
 
 +
In this tutorial, we will learnt how to,
  
 
# Build a '''set''' of blocks to create a '''Control LED''' with '''Push button'''.
 
# Build a '''set''' of blocks to create a '''Control LED''' with '''Push button'''.
 
# Check the '''output''' of the experiment using the simulator
 
# Check the '''output''' of the experiment using the simulator
  
|-  
+
 
|| Slide 6:
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"|
 +
 
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Slide 6:
  
 
'''Assignment'''
 
'''Assignment'''
|| As an assignment, please do the following:
+
 
# Add two buttons and one LED in ElectroBlocks.
+
 
# Connect the first button to pin 3, the second button to pin 4, and the LED to pin 2.
+
# Pressing the first button turns the LED on.
# Create a project with the following functionality:
+
# Pressing the second button turns the LED off.
* Pressing the first button turns the LED on.
+
* Pressing the second button turns the LED off.
+
  
 
'''Hint'''- Don't use a time block.
 
'''Hint'''- Don't use a time block.
|-
 
|| Notice the output of the assignment shown in the video.
 
|-
 
|| '''Slide 7:'''
 
  
'''About Spoken Tutorial project'''
 
|| The video at the following link summarizes the Spoken Tutorial project.
 
  
Please download and watch it.
 
|-
 
|| '''Slide 8:'''
 
  
'''Spoken Tutorial workshops'''
+
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| As an assignment, please do the following:
|| The Spoken Tutorial Project Team conducts workshops and gives certificates.
+
  
For more details, please write to us.
+
# Add two buttons and one LED in ElectroBlocks.
|-
+
# Connect the first button to pin 3, the second button to pin 4, and the LED to pin 2.
||  '''Slide 9:'''
+
# Create a project with the following functionality:
  
'''Answers for THIS Spoken Tutorial'''
 
  
|| Please post your timed queries in this forum.
 
|-
 
|| '''Slide 10:'''
 
  
 +
|-
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| '''Add the Assignment video.mp4 in the main video at 10:54 timestamp.'''
 +
| style="background-color:transparent;border:1pt solid #000000;padding:0.176cm;"| Notice the output of the assignment shown in the video.
  
'''Acknowledgement'''
+
|-
|| Spoken Tutorial project was established by the Ministry of Education(MoE), Govt of India
+
| style="background-color:transparent;border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| '''Slide 7:'''
|-  
+
|| '''Slide 11:'''
+
  
 
'''Thank you'''
 
'''Thank you'''
|| This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.
+
| style="background-color:transparent;border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.
  
 
Thank you for watching.
 
Thank you for watching.
|-
+
 
 
|}
 
|}

Revision as of 12:35, 9 June 2025

Title of the Script:Control LED with Push button

Author: Pratik Nemane

Keywords: Electroblocks, arduino board, 220 ohm resistor, LEDs, breadboard, Push button, video tutorial, spoken tutorial.


Visual Cue Narration
Slide 1:

Title slide.

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

Learning Objective

In this tutorial, we will learn how to,
  1. Build a set of blocks to create a Control LED with Push button.
  2. Check the output of the experiment using the simulator.


Slide 3:

System Requirements

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


https://spoken-tutorial.org

To follow this tutorial,
  • Learner should have a basic knowledge of Electroblocks interface
  • If not, please visit the relevant tutorials on this website.


Open Google Chrome browser.


In New Tab, type

https://electroblocks.org/


Point towards Default Blink LED circuit.

Let us open the Electroblocks platform using Google Chrome browser.


For that Type this url in the address bar.


You will see the default Blink LED circuit on the screen.

Click on the New File/Blank File icon.


A Pop-up window appears.


Click on the OK button.

Click on the New File/Blank file option available on the toolbar.


A pop-up window appears on the screen.


Click on the OK button to start a new project.

Point towards the loop block.


A default loop block appears on the screen.


Let’s drag the default loop block to a convenient place to insert push buttons.



Add the entire Output video.mp4 in the main video at the 1:29 timestamp. We will create this Control LED with Push Button output.


Let’s get started by building a Control LED with Push Button using Electroblocks.

Main Video.mp4


Click on Logic Block.


Point towards all the six Logic Blocks.


Select If then else block, and drag it in the working area.


Place this block inside the loop block.

First we need an If then else block.


Click on the Logic option on the left panel.


You can see six Logic Blocks.


Click on the If then else block and place it inside the loop block.



Click on Sensor


A new list will appear.


Click on the Button option.

We require a button to control the LED.


Click on the Sensors menu on the left panel.


A new list opens.


Click on the Button option.

Point the cursor towards all three blocks.


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


Point towards “Button Setup

You will see three blocks.


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


The Button Setup block is used to configure a push button in the circuit.

Point towards “Connected to PIN#”


Point towards the “USE PULL UP Resistor” checkbox.


Point towards the unchecked checkbox.


Only narration.

By default, this button is connected to pin 2 of Arduino.


Below, you can see the "USE PULLUP Resistor" checkbox.


By default this box is unchecked.


We will leave the box unchecked.


This indicates that an external resistor is connected to the button.

Point the cursor to the “Is Button Pressed” checkbox.


Show the enabled checkbox.

By default, the "Is Button Pressed" checkbox in the button setup is always checked.

It means that the button will be in the pressed state when you run the simulation.

Point towards the “Loop Dropdown”


Point towards

Observe the loop dropdown option in the Button Setup block.


Here, loop 1 is selected.


It indicates that this setting is applied to loop 1 only.

Point to Copy All option.


Check the Copy All checkbox.


Point to button setup block

You can see a checkbox against the Copy all option in the Button setup block.

Check the Copy All checkbox.

This setting ensures that the button setup stays the same, for all the loops in the simulation.

Only narration


Click on the Button option.


Select the Button is pressed? block and drag it in the working area.


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

We will add a button block in the loop.


Click on the Button option.


Select the Button is pressed? block.


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



Only narration.


Click on Add-ons.


A new list will appear.


Now we will add an LED to the circuit.


Click on the Add-ons menu on the left panel.


A new list appears.

Click on the LED option.


Point to the two blocks.


Click on the Turn on LED block and drag it in the working area.


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

Click on the LED option.

You will see that two LED blocks will appear.


Click on the Turn on LED block


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



Point to the grey area.


Point to the simulation screen to show the circuit disappeared.

You will see that the LED and button setup block will turn to grey.


Also, the circuit in the simulation is not seen.

Point towards the LED and push button.


This is an error.


It occurs because both the LED and push button are connected to pin 2 of the arduino.


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



Click on the dropdown arrow in the LED block.


Change the pin number to pin 4.


Point towards the block to show their changes.

Click on the dropdown arrow in the LED block.


Change the pin number to pin 4.


Now, all the blocks appear in normal condition.



Only narration.


Only narration


Click on the Time section.

Let’s make sure that the LED remains turned ON for a sufficient amount of time.


For this, we must add a delay block.


Click on Time on the left panel.

Drag and drop the Wait block for 0.2 second block in the working area.


Place this block below the turn ON LED block.


HaChange the time to 2 seconds in the block.


Drag and drop the Wait block for 0.2 second block to the working area.


Place this block below the turn ON LED block


Change the time to 2 seconds in the block.



Only narration.


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


Now we will turn OFF the LED.


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


A new Turn on LED block will be created in the working space.



Drag and place this new block inside the else section of If then else block.


Click on the dropdown arrow and select OFF


Drag and place this new block inside the else section of If then else block.


Change the state to OFF.


This block turns OFF the LED connected to pin 4.

Only narration.


Click on the Code Icon.

Now we will see the arduino code generated by electroblocks.


Click on the Code Icon.

Highlight Pin 4 line of code. In the void setup function, you will see pin 2 and pin 4 are mentioned.


Pin 4 is assigned to the LED.

Point to OUTPUT


Highlight Pin 2 line of code.


It is termed as OUTPUT because the arduino gives a value to the LED.


Pin 2 is assigned to the push button.


It is termed as INPUT because the arduino takes a value from the push button.



Point to the void loop function.


Highlight the if ((digitalRead(2) == HIGH))


Highlight LED turned HIGH line of code.


This is the void loop function.


It shows the action performed by components and sensors in the experiment.


if ((digitalRead(2) == HIGH))

This line checks if the button connected to pin 2 is pressed or not.


digitalWrite(4, HIGH)

This line describes the LED connected to pin 4 turn ON.



Highlight delay(2000) line of code.


Arduino narration.


Highlight LED turned LOW line of commands.


delay(2000)

This line makes sure that the LED is turned ON for 2 seconds.


In the arduino syntax, 2000 milliseconds represent 2 seconds.

If the condition is false, the code inside the else block will execute


digitalWrite(4, LOW)

This line describes the LED connected to pin 4 turns OFF.



Let’s check the desired result using the simulator.
Click on Home page


Click on the play button

Click on the Home page option from the toolbar.


Click on the Play button to start the simulation.

Show the LED is turned ON.


The visual representation of the simulation shows that:

When the push button is pressed, the LED is turned ON for 2 seconds.


Let us check the output of the LED if we don’t press the pushbutton.

Only narration


Uncheck the Is button is pressed box in the button setup


Click on the play button again.


For this condition, uncheck the Is button pressed checkbox in the button setup block.


Start the simulation again.


Notice that when the push button is not pressed, the LED remains OFF.



Only narration.


check the Is button pressed box in the button setup block.


Click on the Previous Step button to return to the beginning of Step 1.

To see the simulation in the step by step manner.


First check the Is button pressed box in the button setup block.


Then click on the Previous Step button to return to the beginning of Step 1.



Click on the Next step


Point the cursor to the yellow colour outline


Click on the Next Step button and notice the blocks in the working area.


The execution state of the block is highlighted with a yellow colour outline.

Add the entire Output video.mp4 in the main video at the 10:21 timestamp. Notice the output of the experiment.
This brings us to the end of this tutorial.


Let us summarise.

Slide 5:

Summary


In this tutorial, we will learnt how to,

  1. Build a set of blocks to create a Control LED with Push button.
  2. Check the output of the experiment using the simulator


Slide 6:

Assignment


  1. Pressing the first button turns the LED on.
  2. Pressing the second button turns the LED off.

Hint- Don't use a time block.


As an assignment, please do the following:
  1. Add two buttons and one LED in ElectroBlocks.
  2. Connect the first button to pin 3, the second button to pin 4, and the LED to pin 2.
  3. Create a project with the following functionality:


Add the Assignment video.mp4 in the main video at 10:54 timestamp. Notice the output of the assignment shown in the video.
Slide 7:

Thank you

This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.

Thank you for watching.

Contributors and Content Editors

Madhurig, PratikNemane, Pratiknemane