Difference between revisions of "Arduino/C3/Assembly-programming-through-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''' Assembly programming through Arduino.''' |- | 00:07 | In this tutorial, we wi...")
 
 
Line 6: Line 6:
 
|-
 
|-
 
| 00:01
 
| 00:01
| Welcome to the spoken tutorial on''' Assembly programming through Arduino.'''
+
| Welcome to the '''spoken tutorial''' on''' Assembly programming through Arduino.'''
  
 
|-
 
|-
 
| 00:07
 
| 00:07
| In this tutorial, we will learn to: Interface a''' seven-segment Display''' to''' Arduino board'''  
+
| In this tutorial, we will learn to: interface a''' seven-segment Display''' to''' Arduino board''',
  
 
|-
 
|-
 
| 00:15
 
| 00:15
Write an '''assembly program''' to display a digit on '''seven-segment display '''and
+
write an '''assembly program''' to display a digit on '''seven-segment display '''and
  
 
|-
 
|-
 
| 00:21
 
| 00:21
| Display a digit on the '''seven segment display''' using '''7447 IC.'''
+
| display a digit on the '''seven segment display''' using '''7447 IC.'''
  
 
|-
 
|-
 
| 00:28
 
| 00:28
| To follow this tutorial, you should have basic knowledge of : '''Electronics '''and
+
| To follow this tutorial, you should have basic knowledge of electronics and ''Assembly language'''.
 
+
'''Assembly language'''
+
  
 
|-
 
|-
Line 36: Line 34:
 
|-
 
|-
 
| 00:50
 
| 00:50
| To record this tutorial, I am using:  '''Arduino UNO Board'''
+
| To record this tutorial, I am using:  '''Arduino UNO Board''',
  
 
|-
 
|-
 
| 00:56
 
| 00:56
And '''Ubuntu Linux '''operating system version 14.04
+
and '''Ubuntu Linux operating system''' version 14.04.
  
 
|-
 
|-
 
|01:02
 
|01:02
| We also require some external devices such as: '''Breadboard'''
+
| We also require some external devices such as:  
 +
'''Breadboard''',
  
 
|-
 
|-
 
| 01:09
 
| 01:09
| '''Arduino UNO Board'''
+
| '''Arduino UNO Board''',
  
 
|-
 
|-
 
| 01:12
 
| 01:12
| '''Common Anode Seven-Segment Display'''
+
| '''Common Anode Seven-Segment Display''',
  
'''220 ohm Resistor'''
+
'''220 ohm Resistor''',
  
 
|-
 
|-
Line 60: Line 59:
 
|  '''Decoder 7447 IC'''
 
|  '''Decoder 7447 IC'''
  
And '''Jumper Wires'''
+
and '''Jumper Wires'''.
  
 
|-
 
|-
 
| 01:25
 
| 01:25
| In this experiment we will use the '''common anode seven segment display.'''
+
| In this experiment, we will use the '''common anode seven segment display.'''
  
 
|-
 
|-
Line 80: Line 79:
 
|-
 
|-
 
| 01:53
 
| 01:53
| Any one of the '''COM pins '''is connected to the +5Volts through a 220 '''ohm resistor'''.
+
| Any one of the '''COM pins '''is connected to the +5 Volts through a 220 '''ohm resistor'''.
  
 
|-
 
|-
Line 92: Line 91:
 
|-
 
|-
 
| 02:09
 
| 02:09
| Now we will write an '''assembly program''' to turn on the '''Dot LED''' on the '''seven segment display'''.
+
| Now, we will write an '''assembly program''' to turn on the '''Dot LED''' on the '''seven segment display'''.
  
 
|-
 
|-
Line 112: Line 111:
 
|-
 
|-
 
|02:39
 
|02:39
| To install '''avra''' and '''avrdude''', type '''sudo space apt hyphen get space install space avra space avrdude'''
+
| To install '''avra''' and '''avrdude''', type: '''sudo space apt hyphen get space install space avra space avrdude'''.
  
 
|-
 
|-
Line 124: Line 123:
 
|-
 
|-
 
| 03:05
 
| 03:05
| Press ''''Y'''' wherever there is a prompt during the installation, to confirm the configuration.
+
| Press ''''Y'''' wherever there is a prompt during the installation to confirm the configuration.
  
 
|-
 
|-
Line 134: Line 133:
 
| We can see that the installation has been completed successfully.
 
| We can see that the installation has been completed successfully.
  
Let us clear the screen.
+
Let us clear the '''screen'''.
  
 
|-
 
|-
 
| 03:25
 
| 03:25
| Now let us connect the''' Arduino board''' to the computer.
+
| Now, let us connect the''' Arduino board''' to the computer.
  
 
|-
 
|-
 
| 03:29
 
| 03:29
| To check the '''port''' number of '''Arduino''', I'll type '''ls space forward slash dev forward slash ttyACM asterisk'''
+
| To check the '''port''' number of '''Arduino''', I'll type: '''ls space forward slash dev forward slash ttyACM asterisk'''.
  
 
|-
 
|-
 
| 03:41
 
| 03:41
| We can see the output as '''forward slash dev forward slash ttyACM0'''
+
| We can see the output as '''forward slash dev forward slash ttyACM0'''.
  
 
|-
 
|-
 
| 03:49
 
| 03:49
| Here''' ttyACM0''' represents the '''port''' number of '''Arduino'''.
+
| Here,''' ttyACM0''' represents the '''port''' number of '''Arduino'''.
  
 
|-
 
|-
Line 162: Line 161:
 
|-
 
|-
 
| 04:08
 
| 04:08
| We need to include this '''library''' file in the first line of the source code.
+
| We need to include this '''library''' file in the first line of the '''source code'''.
  
 
|-
 
|-
Line 174: Line 173:
 
|-
 
|-
 
| 04:25
 
| 04:25
| Open any text editor and type the following.
+
| Open any '''text editor''' and type the following.
  
 
|-
 
|-
 
| 04:29
 
| 04:29
| '''Semicolon''' represents '''comment statements'''.  
+
| Semicolon represents '''comment statement'''s.  
  
 
|-
 
|-
Line 186: Line 185:
 
|-
 
|-
 
| 04:38
 
| 04:38
| This line tells the '''assembler''' to include the '''m328Pdef.inc file.'''
+
| This line tells the '''assembler''' to include the '''m328Pdef.inc''' file.
  
 
|-
 
|-
Line 198: Line 197:
 
|-
 
|-
 
| 04:55
 
| 04:55
| '''ldi''' stands for '''"load immediate" '''
+
| '''ldi''' stands for '''"load immediate" '''.
  
 
|-
 
|-
 
| 04:59
 
| 04:59
| This sets '''pin PB5''', that is digital '''pin 13''' as output.
+
| This sets '''pin PB5''', that is digital '''pin 13''', as '''output'''.
  
 
|-
 
|-
Line 214: Line 213:
 
|-
 
|-
 
| 05:20
 
| 05:20
| This sets all the pins to '''0 volts '''except '''pin PB5''', (i.e '''digital pin 13''') which is set to '''5 volts.'''
+
| This sets all the pins to '''0 volts '''except '''pin PB5''' i.e '''digital pin 13''' which is set to '''5 volts.'''
  
 
|-
 
|-
Line 226: Line 225:
 
|-
 
|-
 
| 05:44
 
| 05:44
| The '''program''' has to just keep running, in order for the '''LED''' to remain '''ON'''.
+
| The '''program''' has to just keep running in order for the '''LED''' to remain '''ON'''.
  
 
|-
 
|-
 
| 05:50
 
| 05:50
| Save the code as '''dot hyphen led.asm''' file in the '''home slash spoken slash Assembly''' folder.
+
| '''Save''' the '''code''' as '''dot hyphen led.asm''' file in the '''home slash spoken slash Assembly''' folder.
  
 
|-
 
|-
 
| 05:59
 
| 05:59
| This code is available in the '''Code files '''link of this tutorial, as well.  
+
| This code is available in the '''Code files '''link of this tutorial as well.  
  
 
|-
 
|-
Line 250: Line 249:
 
|-
 
|-
 
| 06:16
 
| 06:16
| Type, '''avra space dot hyphen led.asm''' and press '''Enter'''.
+
| Type: '''avra space dot hyphen led.asm''' and press '''Enter'''.
  
 
|-
 
|-
Line 262: Line 261:
 
|-
 
|-
 
| 06:37
 
| 06:37
| Next we need to upload the code to '''Arduino'''.
+
| Next, we need to upload the code to '''Arduino'''.
  
 
|-
 
|-
Line 270: Line 269:
 
|-
 
|-
 
| 06:44
 
| 06:44
| For this, type '''avrdude space hyphen p space atmega328p space hyphen c arduino space hyphen b space 115200 space hyphen capital P space forward slash dev forward slash ttyACM0 space hyphen capital U space flash colon w colon dot hyphen led dot hex '''
+
| For this, type: '''avrdude space hyphen p space atmega328p space hyphen c arduino space hyphen b space 115200 space hyphen capital P space forward slash dev forward slash ttyACM0 space hyphen capital U space flash colon w colon dot hyphen led dot hex'''.
  
 
|-
 
|-
Line 284: Line 283:
 
|-
 
|-
 
| 07:30
 
| 07:30
| Now you can see that the '''Dot LED''' in the '''seven segment''' is glowing.
+
| Now, you can see that the '''Dot LED''' in the '''seven segment''' is glowing.
  
 
|-
 
|-
Line 306: Line 305:
 
|-
 
|-
 
| 08:10
 
| 08:10
| The two '''common pins''' are connected to positive 5Volts through '''resistors'''.
+
| The two '''common pins''' are connected to positive 5 Volts through '''resistors'''.
  
 
|-
 
|-
Line 314: Line 313:
 
|-
 
|-
 
| 08:21
 
| 08:21
| Let us see the source code for this program.
+
| Let us see the '''source code''' for this program.
  
 
|-
 
|-
Line 330: Line 329:
 
|-
 
|-
 
| 08:39
 
| 08:39
| These two lines makes the '''bits 2 to 7 '''on''' PORT D '''as output.
+
| These two lines make the '''bits 2 to 7 '''on''' PORT D '''as output.
  
 
|-
 
|-
 
| 08:45
 
| 08:45
| These two lines makes '''bit 0''' on '''PORT B '''as output.
+
| These two lines make '''bit 0''' on '''PORT B '''as output.
  
 
|-
 
|-
 
| 08:50
 
| 08:50
| These '''bits''' corresponds to the '''digital pins 2 to 8 '''on '''Arduino'''.  
+
| These '''bits''' correspond to the '''digital pins 2 to 8 '''on '''Arduino'''.  
  
 
|-
 
|-
Line 358: Line 357:
 
|-
 
|-
 
| 09:22
 
| 09:22
| Let us save this as '''two.asm''' file.
+
| Let us '''save''' this as '''two.asm''' file.
  
 
|-
 
|-
Line 368: Line 367:
 
|-
 
|-
 
| 09:33
 
| 09:33
| Type, '''avra space two.asm''' and press '''Enter'''.
+
| Type: '''avra space two.asm''' and press '''Enter'''.
  
 
|-
 
|-
 
| 09:39
 
| 09:39
| To upload, press the up arrow to get the previous command.  
+
| To upload, press the up arrow to get the previous '''command'''.  
  
 
|-
 
|-
 
| 09:44
 
| 09:44
| Now change the filename as shown and press '''Enter'''.
+
| Now, change the filename as shown and press '''Enter'''.
  
 
|-
 
|-
 
| 09:50
 
| 09:50
| Now you can see that the digit 2 in the '''seven segment''' is glowing.
+
| Now, you can see that the digit 2 in the '''seven segment''' is glowing.
  
 
|-
 
|-
Line 400: Line 399:
 
|-
 
|-
 
| 10:25
 
| 10:25
| '''Vcc''' and the '''Ground pins '''of the '''decoder''' are connected to '''positive 5Volts''' and the '''Ground pins '''of '''Arduino.'''
+
| '''Vcc''' and the '''Ground pins '''of the '''decoder''' are connected to positive 5 Volts and the '''Ground pins '''of '''Arduino.'''
  
 
|-
 
|-
Line 428: Line 427:
 
|-
 
|-
 
| 11:10
 
| 11:10
| Let us see the source code for this program.
+
| Let us see the '''source code''' for this program.
  
 
|-
 
|-
Line 436: Line 435:
 
|-
 
|-
 
| 11:17
 
| 11:17
| The first two lines makes the '''bits 2''' to '''5''' on '''PORT D''' as output.
+
| The first two lines make the '''bits 2''' to '''5''' on '''PORT D''' as output.
  
 
|-
 
|-
Line 464: Line 463:
 
|-
 
|-
 
| 11:55
 
| 11:55
| Type, '''avra space decoder.asm''' and press '''Enter'''.
+
| Type: '''avra space decoder.asm''' and press '''Enter'''.
 
   
 
   
 
|-
 
|-
Line 472: Line 471:
 
|-
 
|-
 
| 12:07
 
| 12:07
| Now change the filename as shown and press '''Enter'''.
+
| Now, change the filename as shown and press '''Enter'''.
  
 
|-
 
|-
Line 484: Line 483:
 
|-
 
|-
 
|12:24
 
|12:24
| In this tutorial, we learnt to: Interface a''' Seven-segment Display''' to''' Arduino board''' and
+
| In this tutorial, we learnt to: interface a''' Seven-segment Display''' to''' Arduino board''',
  
 
|-
 
|-
 
| 12:31
 
| 12:31
Write an '''assembly program''' to display a digit on '''seven-segment display.'''
+
write an '''assembly program''' to display a digit on '''seven-segment display'''
  
 
|-
 
|-
 
| 12:36
 
| 12:36
And Display a digit on the '''seven segment display''' using '''7447 IC.'''
+
and display a digit on the '''seven segment display''' using '''7447 IC.'''
  
 
|-
 
|-
 
|12:42
 
|12:42
| The video at the following link summarizes the Spoken Tutorial project.
+
| The video at the following link summarizes the '''Spoken Tutorial''' project.
  
 
Please download and watch it.
 
Please download and watch it.
Line 502: Line 501:
 
|-
 
|-
 
| 12:50
 
| 12:50
| The''' Spoken Tutorial Project''' Team: conducts workshops and gives certificates.
+
| The''' Spoken Tutorial Project''' team: conducts workshops and gives certificates.
  
 
For more details, please write to us.
 
For more details, please write to us.
Line 512: Line 511:
 
|-
 
|-
 
| 13:02
 
| 13:02
|  Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.
+
|  Spoken Tutorial project is funded by '''NMEICT, MHRD''', Government of India.
  
 
More information on this mission is available at this link.
 
More information on this mission is available at this link.
Line 520: Line 519:
 
| This tutorial has been contributed by '''FOSSEE '''and''' Spoken Tutorial Project, IIT Bombay'''.  
 
| This tutorial has been contributed by '''FOSSEE '''and''' Spoken Tutorial Project, IIT Bombay'''.  
  
This is Priya from IIT Bombay signing off.
+
This is Priya from '''IIT Bombay''', signing off.
  
 
Thanks for joining.
 
Thanks for joining.
  
 
|}
 
|}

Latest revision as of 11:30, 26 October 2018

Time Narration
00:01 Welcome to the spoken tutorial on Assembly programming through Arduino.
00:07 In this tutorial, we will learn to: interface a seven-segment Display to Arduino board,
00:15 write an assembly program to display a digit on seven-segment display and
00:21 display a digit on the seven segment display using 7447 IC.
00:28 To follow this tutorial, you should have basic knowledge of electronics and Assembly language'.
00:36 Refer to the Additional reading material link of this tutorial to know more about:
00:42 Arduino - Assembly code reference and Arduino ATmega328 Pin mapping.
00:50 To record this tutorial, I am using: Arduino UNO Board,
00:56 and Ubuntu Linux operating system version 14.04.
01:02 We also require some external devices such as:

Breadboard,

01:09 Arduino UNO Board,
01:12 Common Anode Seven-Segment Display,

220 ohm Resistor,

01:18 Decoder 7447 IC

and Jumper Wires.

01:25 In this experiment, we will use the common anode seven segment display.
01:31 Please refer to the basic level tutorial of this series to know more about seven segment display.
01:38 Let us see the connection circuit details.
01:46 The Dot pin of the Seven Segment Display is connected to the pin 13 of Arduino.
01:53 Any one of the COM pins is connected to the +5 Volts through a 220 ohm resistor.
02:00 Refer the pin mapping for Arduino and microcontroller.
02:05 This is the live setup of the connection.
02:09 Now, we will write an assembly program to turn on the Dot LED on the seven segment display.
02:17 We need to install an assembler AVRA and AVRDUDE.
02:23 AVRA is an assembler that will generate a hex file.
02:28 AVRDUDE is used to upload any hex file to the Arduino board.
02:34 Open the terminal by pressing Ctrl + Alt + T keys together.
02:39 To install avra and avrdude, type: sudo space apt hyphen get space install space avra space avrdude.
02:55 Enter the administrative password if prompted and press Enter.
03:01 We can see the installation process has begun.
03:05 Press 'Y' wherever there is a prompt during the installation to confirm the configuration.
03:11 Installation will take some time to complete depending upon the internet speed.
03:17 We can see that the installation has been completed successfully.

Let us clear the screen.

03:25 Now, let us connect the Arduino board to the computer.
03:29 To check the port number of Arduino, I'll type: ls space forward slash dev forward slash ttyACM asterisk.
03:41 We can see the output as forward slash dev forward slash ttyACM0.
03:49 Here, ttyACM0 represents the port number of Arduino.
03:55 You may get a different port number. Make a note of your port number.
04:00 Download m328Pdef.inc file from the Code files link of this tutorial.
04:08 We need to include this library file in the first line of the source code.
04:13 This allows the user to use Register and Bit name when writing assembly programs.
04:20 Let us write an assembly program and upload it to the microcontroller.
04:25 Open any text editor and type the following.
04:29 Semicolon represents comment statements.
04:33 These statements are ignored by the assembler and are not executed.
04:38 This line tells the assembler to include the m328Pdef.inc file.
04:45 We had downloaded this file earlier and in my computer this is the path.
04:51 Note that we have to specify the entire file path.
04:55 ldi stands for "load immediate" .
04:59 This sets pin PB5, that is digital pin 13, as output.
05:05 It tells the assembler to take a working register r16 and load a binary number into it.
05:12 This line tells the compiler to copy the contents of the register r16 into the DDRB register.
05:20 This sets all the pins to 0 volts except pin PB5 i.e digital pin 13 which is set to 5 volts.
05:30 This line copies the same binary number from our storage register r17 to PortB.
05:38 Relative jump statement executes the program in an infinite loop.
05:44 The program has to just keep running in order for the LED to remain ON.
05:50 Save the code as dot hyphen led.asm file in the home slash spoken slash Assembly folder.
05:59 This code is available in the Code files link of this tutorial as well.
06:04 You can download and use it.
06:07 Switch to the terminal.
06:10 Go to the folder where dot hyphen led.asm file is saved.
06:16 Type: avra space dot hyphen led.asm and press Enter.
06:24 This will assemble the code and create a file dot hyphen led.hex.
06:30 Let us see the dot hyphen led.hex file that is generated in the same folder.
06:37 Next, we need to upload the code to Arduino.
06:41 Switch back to the terminal.
06:44 For this, type: avrdude space hyphen p space atmega328p space hyphen c arduino space hyphen b space 115200 space hyphen capital P space forward slash dev forward slash ttyACM0 space hyphen capital U space flash colon w colon dot hyphen led dot hex.
07:16 Here ttyACM0 represents the port number of Arduino.
07:22 dot hyphen led.hex is the file that is generated.

And press Enter.

07:30 Now, you can see that the Dot LED in the seven segment is glowing.
07:36 Pause the tutorial and do the below assignment.

Modify the same code to turn off the Dot LED.

07:44 Next, we will display the digit 2 on the seven segment display.
07:49 To display '2', a,b,d,e,g segments should be high and the other LEDS should be low.
07:58 Connect Pins a, b, c, d, e, f and g of the seven-segment display to pins 2, 3, 4, 5, 6, 7 and 8 of Arduino.
08:10 The two common pins are connected to positive 5 Volts through resistors.
08:17 Let us see the live connection setup.
08:21 Let us see the source code for this program.
08:24 Open any text editor and type the following code.
08:28 As seen earlier, we should first configure the pins as output first.
08:34 Then make it as high or low according to our requirement.
08:39 These two lines make the bits 2 to 7 on PORT D as output.
08:45 These two lines make bit 0 on PORT B as output.
08:50 These bits correspond to the digital pins 2 to 8 on Arduino.
08:56 Here, we are making the pins as high or low corresponding to whatever number we want to display.
09:04 In our case, it is digit two.
09:07 Here, we are writing 0100100 to digital pins 2 to 8 of Arduino.
09:16 This will make all the segments of SSD low, except c and g.
09:22 Let us save this as two.asm file.
09:27 Switch back to the terminal.

Let us clear the screen.

09:33 Type: avra space two.asm and press Enter.
09:39 To upload, press the up arrow to get the previous command.
09:44 Now, change the filename as shown and press Enter.
09:50 Now, you can see that the digit 2 in the seven segment is glowing.
09:56 Pause the tutorial and do the below assignment. Modify the above code to display any other digit from 0 to 9.
10:06 Next, we will use a Decoder to display the number 5 on the Seven Segment Display.
10:12 We are using 7447 IC.
10:16 The a complement to f complement pins of the decoder connect to the a to f pins of Seven Segment Display.
10:25 Vcc and the Ground pins of the decoder are connected to positive 5 Volts and the Ground pins of Arduino.
10:33 Connect the A, B,C,D pins of the Decoder to pins 2,3,4,5 of Arduino.
10:40 Note that this decoder is compatible only with common anode seven segment display.
10:47 Let us see the live connection setup.
10:51 The input pins of the decoder are A,B,C and D.
10:56 A being the lowest significant bit (LSB) and D being the most significant bit (MSB).
11:02 For example, the number 5 is visible on the display when the A,B,C and D inputs are as shown here.
11:10 Let us see the source code for this program.
11:13 Open any text editor and type the following code.
11:17 The first two lines make the bits 2 to 5 on PORT D as output.
11:23 This means we are making digital pins 2 to 5 in Arduino as output pins.
11:29 2 to 5 pins in the Arduino are connected to A, B, C, D pins of decoder.
11:36 The next two lines are giving input of 0101 to decoder inputs.
11:43 This will then be decoded as 5 in the seven segment display.
11:48 Save it as decoder.asm file.
11:52 Switch back to the terminal.
11:55 Type: avra space decoder.asm and press Enter.
12:02 To upload, press the up arrow to get the previous command.
12:07 Now, change the filename as shown and press Enter.
12:13 Now we can see that the digit five in the seven segment is glowing.
12:19 This brings us to the end of this tutorial. Let us summarize.
12:24 In this tutorial, we learnt to: interface a Seven-segment Display to Arduino board,
12:31 write an assembly program to display a digit on seven-segment display
12:36 and display a digit on the seven segment display using 7447 IC.
12:42 The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it.

12:50 The Spoken Tutorial Project team: conducts workshops and gives certificates.

For more details, please write to us.

12:58 Please post your timed queries in this forum.
13:02 Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.

More information on this mission is available at this link.

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

This is Priya from IIT Bombay, signing off.

Thanks for joining.

Contributors and Content Editors

PoojaMoolya, Sandhya.np14