Difference between revisions of "Arduino/C3/AVR-GCC-programming-through-Arduino/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) (Created page with " {|border=1 | '''Time''' | '''Narration''' |- | 00:01 | Welcome to the''' Spoken Tutorial''' on''' AVR-GCC programming through Arduino.''' |- | 00:08 | In this tutorial, w...") |
Sandhya.np14 (Talk | contribs) |
||
Line 10: | Line 10: | ||
|- | |- | ||
| 00:08 | | 00:08 | ||
− | | In this tutorial, we will learn to: | + | | In this tutorial, we will learn to: interface a''' seven segment display''' to''' Arduino board''', |
|- | |- | ||
| 00:15 | | 00:15 | ||
− | | | + | | write an''' AVR-GCC''' program to display a digit on '''seven segment display '''and |
+ | display digits 0 to 9 on the '''seven segment display.''' | ||
|- | |- | ||
Line 22: | Line 23: | ||
|- | |- | ||
| 00:31 | | 00:31 | ||
− | | | + | | electronics, |
|- | |- | ||
| 00:34 | | 00:34 | ||
− | | '''C Programming '''and '''AVR-GCC''' | + | | '''C Programming '''and |
+ | '''AVR-GCC'''. | ||
|- | |- | ||
| 00:39 | | 00:39 | ||
− | | To record this tutorial, I am using: '''Arduino UNO Board '''and '''Ubuntu Linux ''' | + | | To record this tutorial, I am using: '''Arduino UNO Board '''and |
+ | '''Ubuntu Linux operating system''' version 14.04. | ||
|- | |- | ||
Line 50: | Line 53: | ||
|- | |- | ||
| 01:15 | | 01:15 | ||
− | | We also require some external devices such as: '''Seven-Segment Display''' | + | | We also require some external devices such as: '''Seven-Segment Display''', |
|- | |- | ||
| 01:22 | | 01:22 | ||
− | | '''220 ohm Resistor''' | + | | '''220 ohm Resistor''', |
|- | |- | ||
| 01:26 | | 01:26 | ||
− | | '''Breadboard''' | + | | '''Breadboard''', |
|- | |- | ||
Line 64: | Line 67: | ||
| '''Arduino UNO Board''' | | '''Arduino UNO Board''' | ||
− | + | and '''Jumper Wires.''' | |
|- | |- | ||
| 01:33 | | 01:33 | ||
− | | In this experiment we will be using the '''common anode seven-segment display.''' | + | | In this experiment, we will be using the '''common anode seven-segment display.''' |
|- | |- | ||
Line 88: | Line 91: | ||
|- | |- | ||
| 02:02 | | 02:02 | ||
− | |Any one of the '''common''' pins is connected to the '''+ | + | |Any one of the '''common''' pins is connected to the '''+5 Volts''' through a '''resistor'''. |
|- | |- | ||
Line 96: | Line 99: | ||
|- | |- | ||
| 02:12 | | 02:12 | ||
− | | Now we will write an '''AVR-GCC program''' to blink the '''Dot LED''' on the '''seven segment display'''. | + | | Now, we will write an '''AVR-GCC program''' to blink the '''Dot LED''' on the '''seven segment display'''. |
|- | |- | ||
| 02:22 | | 02:22 | ||
− | | We need to install '''AVR-GCC assembler''' and | + | | We need to install '''AVR-GCC assembler''' and an '''AVR-LIBC library'''. |
|- | |- | ||
Line 116: | Line 119: | ||
|- | |- | ||
| 02:48 | | 02:48 | ||
− | | Type | + | | Type: '''sudo space apt hyphen get space install space avr hyphen libc space gcc hyphen avr ''' |
− | + | and press '''Enter'''. | |
|- | |- | ||
Line 144: | Line 147: | ||
|- | |- | ||
| 03:34 | | 03:34 | ||
− | | Now let us connect the''' Arduino board''' to the computer. | + | | Now, let us connect the''' Arduino board''' to the computer. |
|- | |- | ||
| 03:38 | | 03:38 | ||
− | | To check the '''port number '''of '''Arduino''', I | + | | To check the '''port number '''of '''Arduino''', I will type: '''ls space forward slash dev forward slash ttyACM asterisk''' and press '''Enter'''. |
|- | |- | ||
Line 172: | Line 175: | ||
|- | |- | ||
| 04:24 | | 04:24 | ||
− | | Let us write the''' avr-gcc''' program to blink the '''Dot | + | | Let us write the''' avr-gcc''' program to blink the '''Dot LED''' and upload it to the '''microcontroller'''. |
|- | |- | ||
| 04:32 | | 04:32 | ||
− | | Open any text editor and type the following. | + | | Open any '''text editor''' and type the following. |
|- | |- | ||
Line 192: | Line 195: | ||
|- | |- | ||
| 04:56 | | 04:56 | ||
− | | '''Arduino board''' has an LED at PB5. | + | | '''Arduino board''' has an '''LED''' at '''PB5'''. |
|- | |- | ||
| 05:00 | | 05:00 | ||
− | | Set '''PB5''', that is '''pin 13 '''of '''Arduino '''as output. | + | | Set '''PB5''', that is '''pin 13 '''of '''Arduino '''as '''output'''. |
|- | |- | ||
Line 212: | Line 215: | ||
|- | |- | ||
| 05:19 | | 05:19 | ||
− | | Source code that are used in this tutorial are available in the '''Code Files''' link of this tutorial. | + | | '''Source code''' that are used in this tutorial are available in the '''Code Files''' link of this tutorial. |
You can download and use it. | You can download and use it. | ||
Line 230: | Line 233: | ||
|- | |- | ||
| 05:45 | | 05:45 | ||
− | | Type | + | | Type: '''make space FNAME in capital equals dot hyphen blink ''' and press '''Enter'''. |
This '''command''' creates a ''' dot hex''' file and uploads it to the '''Arduino'''. | This '''command''' creates a ''' dot hex''' file and uploads it to the '''Arduino'''. | ||
Line 236: | Line 239: | ||
|- | |- | ||
| 06:00 | | 06:00 | ||
− | | Now, you can see that | + | | Now, you can see that the '''Dot''' '''LED''' in the '''seven segment''' is blinking. |
|- | |- | ||
Line 244: | Line 247: | ||
|- | |- | ||
|06:11 | |06:11 | ||
− | | To display '2', '''a | + | | To display '2', '''a, b, d, e, g segments '''should be high and the other '''LEDS''' should be low. |
|- | |- | ||
Line 252: | Line 255: | ||
|- | |- | ||
| 06:32 | | 06:32 | ||
− | | The common '''pin''' is connected to '''+ | + | | The common '''pin''' is connected to '''+5 Volts''' through '''resistor'''. |
|- | |- | ||
Line 260: | Line 263: | ||
|- | |- | ||
| 06:42 | | 06:42 | ||
− | | Let us see the source code for this program. | + | | Let us see the '''source code''' for this program. |
|- | |- | ||
| 06:46 | | 06:46 | ||
− | | Open any text editor and type the following code. | + | | Open any '''text editor''' and type the following code. |
|- | |- | ||
| 06:50 | | 06:50 | ||
− | | The first two lines of the code in the '''main function''' set '''pins 2 '''to '''8 '''as '''output pins.''' | + | | The first two lines of the code in the ''''main' function''' set '''pins 2 '''to '''8 '''as '''output pins.''' |
|- | |- | ||
Line 290: | Line 293: | ||
|- | |- | ||
| 07:21 | | 07:21 | ||
− | | Type '''make space FNAME''' in capital '''equals two''' and press '''Enter'''. | + | | Type: '''make space FNAME''' in capital '''equals two''' and press '''Enter'''. |
|- | |- | ||
Line 298: | Line 301: | ||
|- | |- | ||
| 07:38 | | 07:38 | ||
− | | Pause the tutorial and do the below assignment. Modify the above code to display any other | + | | Pause the tutorial and do the below assignment. Modify the above code to display any other digit from '''0 '''to''' 9'''. |
|- | |- | ||
Line 310: | Line 313: | ||
|- | |- | ||
| 07:57 | | 07:57 | ||
− | | Let us see the source code for this program. Open any text editor and type the following code. | + | | Let us see the '''source code''' for this program. Open any text editor and type the following code. |
|- | |- | ||
Line 316: | Line 319: | ||
| The '''for loop''' is used to count from 0 to 9. | | The '''for loop''' is used to count from 0 to 9. | ||
− | Each time, the variable | + | Each time, the variable ''''i'''' is incremented by one and the value is passed to ''''sevenseg' function'''. |
|- | |- | ||
| 08:16 | | 08:16 | ||
− | | The '''sevenseg function '''receives an integer ranging from 0 to 9. | + | | The ''''sevenseg' function '''receives an integer ranging from 0 to 9. |
Based on the input, the '''case''' structure is executed. | Based on the input, the '''case''' structure is executed. | ||
Line 326: | Line 329: | ||
|- | |- | ||
| 08:27 | | 08:27 | ||
− | | Thus displaying the | + | | Thus displaying the digits from '''0 '''to '''9'''. |
|- | |- | ||
Line 338: | Line 341: | ||
|- | |- | ||
| 08:40 | | 08:40 | ||
− | | Type '''make space FNAME''' in capital '''equals counter''' and press '''Enter'''. | + | | Type: '''make space FNAME''' in capital '''equals counter''' and press '''Enter'''. |
|- | |- | ||
| 08:50 | | 08:50 | ||
− | | Now we can see the ''' | + | | Now, we can see the digits '''0 '''to '''9 '''are displayed in the '''seven segment display'''. |
|- | |- | ||
Line 350: | Line 353: | ||
|- | |- | ||
| 09:06 | | 09:06 | ||
− | | In this tutorial, we learnt to | + | | In this tutorial, we learnt to interface a''' Seven-segment display''' to''' Arduino board, ''' |
|- | |- | ||
| 09:13 | | 09:13 | ||
− | | | + | | write an''' AVR-GCC''' program to display a digit on '''seven-segment display '''and |
|- | |- | ||
| 09:19 | | 09:19 | ||
− | | | + | | display digits '''0 '''to '''9 '''on the '''Seven segment display.''' |
|- | |- | ||
| 09:24 | | 09:24 | ||
− | | 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 368: | Line 371: | ||
|- | |- | ||
| 09:32 | | 09:32 | ||
− | | The''' Spoken Tutorial Project''' | + | | 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 378: | Line 381: | ||
|- | |- | ||
| 09:46 | | 09:46 | ||
− | | 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 384: | Line 387: | ||
|- | |- | ||
| 09:56 | | 09:56 | ||
− | | This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, | + | | This tutorial has been contributed by '''FOSSEE''' and '''Spoken Tutorial Project, IIT Bombay'''. |
− | This is Priya from IIT Bombay. Thanks for joining. | + | This is Priya from '''IIT Bombay'''. Thanks for joining. |
|} | |} |
Revision as of 16:29, 26 October 2018
Time | Narration |
00:01 | Welcome to the Spoken Tutorial on AVR-GCC programming through Arduino. |
00:08 | In this tutorial, we will learn to: interface a seven segment display to Arduino board, |
00:15 | write an AVR-GCC program to display a digit on seven segment display and
display digits 0 to 9 on the seven segment display. |
00:27 | To follow this tutorial, you should have basic knowledge of : |
00:31 | electronics, |
00:34 | C Programming and
AVR-GCC. |
00:39 | To record this tutorial, I am using: Arduino UNO Board and
Ubuntu Linux operating system version 14.04. |
00:50 | GCC stands for GNU Compiler Collection. |
00:54 | It is a compiler which supports various programming languages. |
00:59 | AVR-GCC is a part of GCC and supports compiling C programs for AVR microcontrollers. |
01:08 | Since Arduino uses ATMEGA328P, this is a suitable compiler. |
01:15 | We also require some external devices such as: Seven-Segment Display, |
01:22 | 220 ohm Resistor, |
01:26 | Breadboard, |
01:28 | Arduino UNO Board
and Jumper Wires. |
01:33 | In this experiment, we will be using the common anode seven-segment display. |
01:39 | Please refer to the basic level tutorials of this series to know more about Seven segment display. |
01:46 | Refer the pin mapping for Arduino and microcontroller. |
01:51 | Do the circuit connection as shown here. |
01:55 | The Dot pin of the Seven Segment Display is connected to the pin 13 of the Arduino. |
02:02 | Any one of the common pins is connected to the +5 Volts through a resistor. |
02:09 | This is the live setup of the connection. |
02:12 | Now, we will write an AVR-GCC program to blink the Dot LED on the seven segment display. |
02:22 | We need to install AVR-GCC assembler and an AVR-LIBC library. |
02:29 | AVR-GCC will generate a hex file and upload it to Arduino board. |
02:35 | AVR-LIBC contains the required library files that can be used in the program. |
02:42 | Open the terminal by pressing Ctrl + Alt + T keys together. |
02:48 | Type: sudo space apt hyphen get space install space avr hyphen libc space gcc hyphen avr
and press Enter. |
03:03 | Enter the administrative password if prompted and press Enter. |
03:09 | We can see the installation process has begun. |
03:13 | Press 'Y' wherever there is a prompt during installation to confirm the configuration. |
03:20 | Installation will take some time to complete depending upon the internet speed. |
03:26 | We can see that the installation has been completed successfully.
Let me clear the terminal. |
03:34 | Now, let us connect the Arduino board to the computer. |
03:38 | To check the port number of Arduino, I will type: ls space forward slash dev forward slash ttyACM asterisk and press Enter. |
03:51 | We can see the output as shown. Here ttyACM0 represents the port number of Arduino. |
04:00 | You may get a different port number. Make a note of your port number. |
04:06 | Download the file Makefile from the Code files link of this tutorial. |
04:12 | Makefile enables us to create a dot hex file and upload it to Arduino. |
04:19 | Save the Makefile in the folder where you will be saving the C program. |
04:24 | Let us write the avr-gcc program to blink the Dot LED and upload it to the microcontroller. |
04:32 | Open any text editor and type the following. |
04:36 | We have to include the libraries required for our program. |
04:41 | avr slash io dot h contains all the basic libraries required to perform the input and output operations. |
04:50 | util slash delay dot h contains the libraries for the delay function. |
04:56 | Arduino board has an LED at PB5. |
05:00 | Set PB5, that is pin 13 of Arduino as output. |
05:05 | Sending 0 to PB5 turns on the LED. |
05:09 | Sending 1 to PB5 turns off the LED. |
05:13 | These two steps will run in an infinite while loop making the LED blink. |
05:19 | Source code that are used in this tutorial are available in the Code Files link of this tutorial.
You can download and use it. |
05:28 | I’ll save the code as dot hyphen blink dot c in the Downloads folder. |
05:37 | Switch to the terminal. |
05:39 | Go to the Downloads folder where dot hyphen blink dot c file is saved. |
05:45 | Type: make space FNAME in capital equals dot hyphen blink and press Enter.
This command creates a dot hex file and uploads it to the Arduino. |
06:00 | Now, you can see that the Dot LED in the seven segment is blinking. |
06:06 | Next, we will display digit 2 on the seven segment display. |
06:11 | To display '2', a, b, d, e, g segments should be high and the other LEDS should be low. |
06:19 | Pins a, b, c, d, e, f and g of the seven segment display are connected to the pins 2, 3, 4, 5, 6, 7 and 8 of the Arduino respectively. |
06:32 | The common pin is connected to +5 Volts through resistor. |
06:37 | Let us see the live connection setup. |
06:42 | Let us see the source code for this program. |
06:46 | Open any text editor and type the following code. |
06:50 | The first two lines of the code in the 'main' function set pins 2 to 8 as output pins. |
06:58 | The codes inside the while loop are used to control the state of the respective LEDs. |
07:05 | Sending 0 will cause the LED to glow and sending 1 will turn it off. |
07:11 | Save it as two.c file. |
07:15 | Switch back to the terminal.
Clear the terminal now. |
07:21 | Type: make space FNAME in capital equals two and press Enter. |
07:30 | Now you can see that the digit two in the seven segment is glowing. |
07:38 | Pause the tutorial and do the below assignment. Modify the above code to display any other digit from 0 to 9. |
07:48 | Next, we will display the numbers 0 to 9 on the Seven Segment Display. |
07:54 | Setup remains the same. |
07:57 | Let us see the source code for this program. Open any text editor and type the following code. |
08:04 | The for loop is used to count from 0 to 9.
Each time, the variable 'i' is incremented by one and the value is passed to 'sevenseg' function. |
08:16 | The 'sevenseg' function receives an integer ranging from 0 to 9.
Based on the input, the case structure is executed. |
08:27 | Thus displaying the digits from 0 to 9. |
08:32 | Save it as counter.c file. |
08:36 | Switch back to the terminal and clear it. |
08:40 | Type: make space FNAME in capital equals counter and press Enter. |
08:50 | Now, we can see the digits 0 to 9 are displayed in the seven segment display. |
09:02 | This brings us to the end of this tutorial. Let us summarize. |
09:06 | In this tutorial, we learnt to interface a Seven-segment display to Arduino board, |
09:13 | write an AVR-GCC program to display a digit on seven-segment display and |
09:19 | display digits 0 to 9 on the Seven segment display. |
09:24 | The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it. |
09:32 | The Spoken Tutorial Project team conducts workshops and gives certificates.
For more details, please write to us. |
09:42 | Please post your timed queries in this forum. |
09:46 | Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.
More information on this mission is available at this link. |
09:56 | This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.
This is Priya from IIT Bombay. Thanks for joining. |