Difference between revisions of "Arduino/C2/Display-counter-using-Arduino/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| Border = 1 | '''Time''' |'''Narration''' |- | 00:01 | Welcome to the''' Spoken Tutorial''' on''' Display counter using Arduino.''' |- |00:07 |In this tutorial, we will le...")
 
 
Line 11: Line 11:
 
|In this tutorial, we will learn to:
 
|In this tutorial, we will learn to:
  
Connect an''' LCD''' and a '''Push button''' to''' Arduino''' board and
+
connect an''' LCD''' and a '''Push button''' to''' Arduino''' board and
 
   
 
   
Write a program to increase the count whenever the '''pushbutton''' is pressed'''.'''
+
write a program to increase the count whenever the '''pushbutton''' is pressed.
  
 
|-
 
|-
Line 19: Line 19:
 
| To follow this tutorial, you should have:
 
| To follow this tutorial, you should have:
  
Basic knowledge of''' Electronics '''and
+
basic knowledge of electronics and
  
Basic knowledge of''' C''' or''' C++''' programming language
+
basic knowledge of''' C''' or''' C++''' programming language.
  
 
|-
 
|-
Line 27: Line 27:
 
| To record this tutorial, I am using:
 
| To record this tutorial, I am using:
  
'''Arduino UNO Board'''
+
'''Arduino UNO Board''',
'''Ubuntu Linux 14.04''' operating system and
+
 
'''Arduino IDE'''
+
'''Ubuntu Linux 14.04 operating system''' and
 +
 
 +
'''Arduino IDE'''.
  
 
|-
 
|-
 
| 00:47
 
| 00:47
| In an earlier tutorial in this series, we had created a circuit using '''Arduino''' and '''LCD'''.
+
| In an earlier tutorial, in this series, we had created a circuit using '''Arduino''' and '''LCD'''.
 
We will use the same '''circuit''' in this tutorial.
 
We will use the same '''circuit''' in this tutorial.
  
 
|-
 
|-
 
| 01:00
 
| 01:00
| Here, we will add a '''pushbutton''' and make a simple counter.
+
| Here, we will add a '''pushbutton''' and make a simple '''counter'''.
  
 
|-
 
|-
 
| 01:06
 
| 01:06
|We have already learnt about the working of pushbutton in an earlier tutorial.
+
|We have already learnt about the working of '''pushbutton''' in an earlier tutorial.
  
 
|-
 
|-
 
| 01:12
 
| 01:12
| Now let us learn the connection circuit details.
+
| Now, let us learn the connection '''circuit''' details.
  
 
|-
 
|-
Line 54: Line 56:
 
|-
 
|-
 
| 01:22
 
| 01:22
|The''' pushbutton''' is connected to '''pin '''number''' 7 '''and a '''100 ohm resistor''' is connected to the '''ground'''.
+
|The''' pushbutton''' is connected to '''pin number 7 '''and a '''100 ohm resistor''' is connected to the '''ground'''.
  
 
|-
 
|-
Line 62: Line 64:
 
|-
 
|-
 
| 01:37
 
| 01:37
| This is the live setup of the connection, as shown in the circuit diagram.
+
| This is the live setup of the connection as shown in the circuit diagram.
  
 
|-
 
|-
 
| 01:44
 
| 01:44
| Now we will write a program in the '''Arduino IDE.'''So let’s switch to the '''Arduino IDE'''.
+
| Now, we will write a program in the '''Arduino IDE.''' So, let’s switch to the '''Arduino IDE'''.
  
 
|-
 
|-
Line 74: Line 76:
 
|-
 
|-
 
| 01:59
 
| 01:59
| Type the code as shown.
+
| Type the '''code''' as shown.
  
 
|-
 
|-
Line 82: Line 84:
 
|-
 
|-
 
| 02:08
 
| 02:08
|Here, '''pin '''number''' 12''' is initialized as '''Register''' '''Select '''and '''pin '''number''' 11''' as '''Enable.'''
+
|Here, '''pin '''number''' 12''' is initialized as '''Register Select '''and '''pin '''number''' 11''' as '''Enable.'''
  
 
|-
 
|-
Line 90: Line 92:
 
|-
 
|-
 
| 02:25
 
| 02:25
| In the '''void setup function''', type '''lcd.begin 16 comma 2 '''as shown.
+
| In the '''void setup''' function, type: '''lcd.begin 16 comma 2 '''as shown.
This command initializes the '''LCD''' with rows and columns.
+
This '''command''' initializes the '''LCD''' with rows and columns.
  
 
|-
 
|-
 
| 02:41
 
| 02:41
| Next we will setup the '''pin '''number''' 7''' as '''INPUT'''.Type the code as shown.
+
| Next we will setup the '''pin '''number''' 7''' as '''INPUT'''. Type the code as shown.
  
 
|-
 
|-
Line 109: Line 111:
 
|-
 
|-
 
| 03:11
 
| 03:11
| We will write a simple '''if statement''' to check whether the '''pushbutton''' is pressed or not.
+
| We will write a simple ''''if' statement''' to check whether the '''pushbutton''' is pressed or not.
  
 
|-
 
|-
Line 127: Line 129:
 
|-
 
|-
 
| 03:43
 
| 03:43
| Here we see the message '''“button pressed”''' in the '''LCD'''.  
+
| Here, we see the message '''“button pressed”''' in the '''LCD'''.  
 
It shows that the '''pushbutton''' is working successfully.
 
It shows that the '''pushbutton''' is working successfully.
  
 
|-
 
|-
 
| 03:54
 
| 03:54
| Next we will modify the program to set a '''counter'''.
+
| Next, we will modify the program to set a '''counter'''.
  
 
|-
 
|-
 
| 03:58
 
| 03:58
| We need a variable for counter. Now, we will initialize the variable '''count''' to '''zero'''.
+
| We need a variable for counter. Now, we will initialize the variable '''count''' to zero.
  
 
|-
 
|-
Line 164: Line 166:
 
|-
 
|-
 
| 04:52
 
| 04:52
| So, we will write a '''while statement,''' as shown here.
+
| So, we will write a ''''while' statement''' as shown here.
  
 
|-
 
|-
Line 174: Line 176:
 
|-
 
|-
 
| 05:07
 
| 05:07
|When you release the button, the state is '''LOW''' and it will come out of the '''while''' '''loop'''.
+
|When you release the button, the state is '''LOW''' and it will come out of the ''''while' loop'''.
  
 
|-
 
|-
Line 186: Line 188:
 
|-
 
|-
 
| 05:26
 
| 05:26
|Inside the '''void setup function''', we have initialized the '''LCD''' with 16 columns and 2 rows.
+
|Inside the '''void setup''' function, we have initialized the '''LCD''' with 16 columns and 2 rows.
 
Then the '''pinMode''' is input for the '''pin '''number''' 7'''.
 
Then the '''pinMode''' is input for the '''pin '''number''' 7'''.
  
 
|-
 
|-
 
| 05:42
 
| 05:42
|In the''' void loop function''', we are checking the condition whether the '''pushbutton''' is '''HIGH''' or not.
+
|In the''' void loop''' function, we are checking the condition whether the '''pushbutton''' is '''HIGH''' or not.
  
 
|-
 
|-
 
| 05:49
 
| 05:49
|When the '''pushbutton''' is pressed, the cursor is set to position zero comma zero.
+
|When the '''pushbutton''' is pressed, the '''cursor''' is set to position zero comma zero.
  
 
|-
 
|-
 
| 05:56
 
| 05:56
|The '''lcd.print statement '''will print the count value.
+
|The '''lcd.print''' statement will print the count value.
 
Initially '''count''' is zero. '''Count plus plus''' would be 1.
 
Initially '''count''' is zero. '''Count plus plus''' would be 1.
  
 
|-
 
|-
 
| 06:09
 
| 06:09
|When the button is released, it will break the '''while''' '''loop''' and come out of the loop.
+
|When the button is released, it will break the '''while loop''' and come out of the loop.
  
 
|-
 
|-
Line 216: Line 218:
 
|-
 
|-
 
| 06:27
 
| 06:27
| Now I'll press the button once and release it.
+
| Now, I'll press the button once and release it.
  
 
|-
 
|-
 
| 06:32
 
| 06:32
| Again I'll press and release the button.You can see that the count is increased whenever the button is pressed.
+
| Again I'll press and release the button. You can see that the count is increased whenever the button is pressed.
  
 
|-
 
|-
Line 230: Line 232:
 
|In this tutorial, we learnt to:
 
|In this tutorial, we learnt to:
  
Connect an''' LCD''' and '''pushbutton''' to''' Arduino''' board and
+
connect an''' LCD''' and '''pushbutton''' to''' Arduino''' board and
 
   
 
   
Write a program to display the count''' '''whenever the pushbutton is pressed.
+
write a program to display the count whenever the '''pushbutton''' is pressed.
  
 
|-
 
|-
Line 240: Line 242:
 
Change the same program to display the count as 2,4,6 and so on.
 
Change the same program to display the count as 2,4,6 and so on.
  
'''Compile''' and '''upload''' the program and
+
'''Compile''' and '''upload''' the program.
  
Observe the count displayed in the '''LCD'''.
+
And, observe the count displayed in the '''LCD'''.
  
 
|-
 
|-
 
| 07:21
 
| 07:21
| The video at the following link summarizes the Spoken Tutorial project. Please download and watch it.
+
| The video at the following link summarizes the '''Spoken Tutorial''' project. Please download and watch it.
  
 
|-
 
|-
 
| 07:29
 
| 07:29
| The''' Spoken Tutorial Project''' Team:
+
| The''' Spoken Tutorial Project''' tTeam:
conducts workshops and gives certificates.For more details, please write to us.
+
conducts workshops and gives certificates. For more details, please write to us.
  
 
|-
 
|-
Line 259: Line 261:
 
|-
 
|-
 
| 07:42
 
| 07:42
| Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.More information on this mission is available at this link.
+
| Spoken Tutorial project is funded by '''NMEICT, MHRD''', Government of India. More information on this mission is available at this link.
  
 
|-
 
|-
 
| 07:53
 
| 07:53
|This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, '''IIT Bombay'''. Thanks for watching.
+
|This tutorial has been contributed by '''FOSSEE''' and '''Spoken Tutorial Project, '''IIT Bombay''''''. Thanks for watching.
  
 
|}
 
|}

Latest revision as of 14:04, 23 October 2018

Time Narration
00:01 Welcome to the Spoken Tutorial on Display counter using Arduino.
00:07 In this tutorial, we will learn to:

connect an LCD and a Push button to Arduino board and

write a program to increase the count whenever the pushbutton is pressed.

00:22 To follow this tutorial, you should have:

basic knowledge of electronics and

basic knowledge of C or C++ programming language.

00:34 To record this tutorial, I am using:

Arduino UNO Board,

Ubuntu Linux 14.04 operating system and

Arduino IDE.

00:47 In an earlier tutorial, in this series, we had created a circuit using Arduino and LCD.

We will use the same circuit in this tutorial.

01:00 Here, we will add a pushbutton and make a simple counter.
01:06 We have already learnt about the working of pushbutton in an earlier tutorial.
01:12 Now, let us learn the connection circuit details.
01:17 A pushbutton is connected to a 100 ohm resistor.
01:22 The pushbutton is connected to pin number 7 and a 100 ohm resistor is connected to the ground.
01:31 All other connections are exactly the same as in our previous experiment.
01:37 This is the live setup of the connection as shown in the circuit diagram.
01:44 Now, we will write a program in the Arduino IDE. So, let’s switch to the Arduino IDE.
01:54 First, we need to include the Liquid crystal library.
01:59 Type the code as shown.
02:02 I have initialized a variable lcd of type LiquidCrystal.
02:08 Here, pin number 12 is initialized as Register Select and pin number 11 as Enable.
02:19 The next 4 parameters represent data lines of LCD.
02:25 In the void setup function, type: lcd.begin 16 comma 2 as shown.

This command initializes the LCD with rows and columns.

02:41 Next we will setup the pin number 7 as INPUT. Type the code as shown.
02:49 In another way, we can store the pin number in a variable pbutton.

Let us define the pbutton variable as shown.

03:01 Now we will write the code for void loop.

Whenever the pushbutton is pressed, one count is increased on the LCD.

03:11 We will write a simple 'if' statement to check whether the pushbutton is pressed or not.
03:19 Before displaying the count, let us check the status of the button.
03:25 This command will set the cursor position in the LCD.

lcd.print will print the message.

03:35 We will now compile and upload the program. Now, I will press the pushbutton.
03:43 Here, we see the message “button pressed” in the LCD.

It shows that the pushbutton is working successfully.

03:54 Next, we will modify the program to set a counter.
03:58 We need a variable for counter. Now, we will initialize the variable count to zero.
04:08 Modify the print statement as shown here.

count++ will increase the count by one, each time the button is pressed.

04:21 Let us now compile and upload the program. Now, I will press the pushbutton.
04:29 It didn't work as expected. We see a different count displayed here.

Why is this so?

04:37 This is because we specified the status for button pressed.

But we didn't mention the status for button released.

04:46 The output shows the incremented number based on the button pressed time.
04:52 So, we will write a 'while' statement as shown here.
04:57 This will display the count when the pushbutton is in pressed state.

That means the pin 7 is in HIGH mode.

05:07 When you release the button, the state is LOW and it will come out of the 'while' loop.
05:14 Let me explain the program.
05:17 The program starts with initialization of the LCD. We have the variable pbutton and count.
05:26 Inside the void setup function, we have initialized the LCD with 16 columns and 2 rows.

Then the pinMode is input for the pin number 7.

05:42 In the void loop function, we are checking the condition whether the pushbutton is HIGH or not.
05:49 When the pushbutton is pressed, the cursor is set to position zero comma zero.
05:56 The lcd.print statement will print the count value.

Initially count is zero. Count plus plus would be 1.

06:09 When the button is released, it will break the while loop and come out of the loop.
06:15 Again, if you press the button, the next iteration begins and it increases the count.
06:23 Let us compile and upload the program.
06:27 Now, I'll press the button once and release it.
06:32 Again I'll press and release the button. You can see that the count is increased whenever the button is pressed.
06:42 This brings us to the end of this tutorial. Let us summarize.
06:47 In this tutorial, we learnt to:

connect an LCD and pushbutton to Arduino board and

write a program to display the count whenever the pushbutton is pressed.

07:03 Do the following assignment.

Change the same program to display the count as 2,4,6 and so on.

Compile and upload the program.

And, observe the count displayed in the LCD.

07:21 The video at the following link summarizes the Spoken Tutorial project. Please download and watch it.
07:29 The Spoken Tutorial Project tTeam:

conducts workshops and gives certificates. For more details, please write to us.

07:38 Please post your timed queries in this forum.
07:42 Spoken Tutorial project is funded by NMEICT, MHRD, Government of India. More information on this mission is available at this link.
07:53 This tutorial has been contributed by FOSSEE' and Spoken Tutorial Project, IIT Bombay'. Thanks for watching.

Contributors and Content Editors

Pratik kamble, Sandhya.np14