Main.AVRProgramming2 History

Hide minor edits - Show changes to markup

March 01, 2010, at 03:49 PM by 18.111.79.246 -
Changed lines 4-6 from:
Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor. Here's what my file looks like in the TextEdit application:

A simple and free editing program for Windows is Notepad++.

to:
Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor. For Windows, a simple and free editing program is Notepad++. Here's what my file looks like in the TextEdit application: \\\
March 01, 2010, at 03:48 PM by 18.111.79.246 -
Added lines 5-7:

A simple and free editing program for Windows is Notepad++.

February 25, 2010, at 07:57 AM by 66.92.79.106 -
Changed line 32 from:

Let's look at the fabric PCB circuit to see why this piece of code would cause the LED on our boards to light up. Here's what the circuit looks like (view from above):\\\

to:

Let's look at the fabric PCB circuit to see why this piece of code would cause the LED on our board to light up. Here's what the circuit looks like (view from above):\\\

Changed line 34 from:

Notice how the + side of the LED is attached to b0 and the - side of the LED is attached to ground through a resistor. -'

to:

Notice how the + side of the LED is attached to b0 and the - side of the LED is attached to ground through a resistor. When b0 is High, at +5V, current runs through the LED, causing it to turn on. When b0 is Low, at 0V, both sides of the LED are attached to ground, so no current flows and the LED turns off.-'

Changed lines 44-45 from:

On a Mac, type the following command in Terminal: make && make install
On a PC, type the following command: make && make installPC-' \\

to:

Type the following command in Terminal: make && make install \\

February 25, 2010, at 07:49 AM by 66.92.79.106 -
Changed lines 31-34 from:

_delay_ms(1000); this statement tells the ATtiny to do nothing for 1 second (1000 milliseconds)-' \\

to:

_delay_ms(1000); this statement tells the ATtiny to do nothing for 1 second (1000 milliseconds)

Let's look at the fabric PCB circuit to see why this piece of code would cause the LED on our boards to light up. Here's what the circuit looks like (view from above):



Notice how the + side of the LED is attached to b0 and the - side of the LED is attached to ground through a resistor. -'

February 24, 2010, at 06:17 PM by 18.111.95.214 -
Changed line 49 from:

5. Use alligator clips to attach a switch to pin b2 and edit the code so that the LED attached to b0 comes on when the switch is pressed

to:

5. Use alligator clips to attach a switch to pin b1 and edit the code so that the LED attached to b0 comes on when the switch is pressed

February 24, 2010, at 06:16 PM by 18.111.95.214 -
Changed line 54 from:

For the official AVR C programming language reference see: AVR libc documentation-' \\

to:

For the official AVR C programming language reference see: AVR libc documentation

February 24, 2010, at 06:16 PM by 18.111.95.214 -
Changed line 45 from:

4. Use alligator clips to attach a second LED to pin b1 and edit the code to get that LED to blink.

to:

4. Use alligator clips to attach a second LED to pin b3 and edit the code to get that LED to blink.

Changed lines 50-54 from:
to:



For the official AVR C programming language reference see: AVR libc documentation-' \\

February 24, 2010, at 12:16 PM by 18.111.95.214 -
Added line 46:

\\

February 24, 2010, at 12:16 PM by 18.111.95.214 -
Changed lines 6-7 from:

This program is written in the C programming language.

to:

This program is written in the C programming language.

Changed lines 31-32 from:

_delay_ms(1000); this statement tells the ATtiny to do nothing for 1 second (1000 milliseconds)-'

to:

_delay_ms(1000); this statement tells the ATtiny to do nothing for 1 second (1000 milliseconds)-' \\

Changed lines 37-38 from:
to:


Changed lines 42-43 from:

On a PC, type the following command: make && make installPC-'

to:

On a PC, type the following command: make && make installPC-'

Added line 46:

\\

February 24, 2010, at 12:15 PM by 18.111.95.214 -
Changed lines 46-47 from:
to:
February 24, 2010, at 12:14 PM by 18.111.95.214 -
Added lines 38-47:

3. Edit the code to get the LED to blink at a different speed.

To upload your edited code to your circuit do the following:

On a Mac, type the following command in Terminal: make && make install
On a PC, type the following command: make && make installPC

4. Use alligator clips to attach a second LED to pin b1 and edit the code to get that LED to blink.

5. Use alligator clips to attach a switch to pin b2 and edit the code so that the LED attached to b0 comes on when the switch is pressed

February 24, 2010, at 12:07 PM by 18.111.95.214 -
Changed lines 27-30 from:

b0High();
_delay_ms(1000);
b0Low();
_delay_ms(1000);-'

to:

b0High(); this statement sets pin b0 to 5 volts. For our circuit this turns the LED attached to b0 ON.
_delay_ms(1000); this statement tells the ATtiny to do nothing for 1 second (1000 milliseconds)
b0Low(); this statement sets pin b0 to 0 volts or ground. For our circuit this turns the LED OFF.
_delay_ms(1000); this statement tells the ATtiny to do nothing for 1 second (1000 milliseconds)-'

February 24, 2010, at 12:04 PM by 18.111.95.214 -
Changed lines 30-31 from:

_delay_ms(1000); -'

to:

_delay_ms(1000);-'

February 24, 2010, at 12:04 PM by 18.111.95.214 -
Changed line 22 from:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like:-' \\

to:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like:-' \\\

Changed line 24 from:

b3Input(); this statement sets up pin b3 to read information from a switch\\\-'

to:

b3Input(); this statement sets up pin b3 to read information from a switch-'\\\

February 24, 2010, at 12:03 PM by 18.111.95.214 -
Changed lines 23-25 from:

'- b1Output(); this statement sets up pin b1 to control an output like a light or motor
b3Input(); this statement sets up pin b3 to read information from a switch

Main Action Area\\

to:

b1Output(); this statement sets up pin b1 to control an output like a light or motor
b3Input(); this statement sets up pin b3 to read information from a switch\\\
'-Main Action Area\\

February 24, 2010, at 12:02 PM by 18.111.95.214 -
Changed line 23 from:
'- b1Output(); this statement sets up pin b1 to control an output like a light or motor\\
to:

'- b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

February 24, 2010, at 12:01 PM by 18.111.95.214 -
Changed lines 22-23 from:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like:

b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

to:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like:-'
->'- b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

February 24, 2010, at 12:00 PM by 18.111.95.214 -
Changed lines 22-23 from:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like: \\-' '-b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

to:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like:

b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

February 24, 2010, at 11:59 AM by 18.111.95.214 -
Changed line 23 from:

b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

to:

'-b1Output(); this statement sets up pin b1 to control an output like a light or motor\\

February 24, 2010, at 11:59 AM by 18.111.95.214 -
Changed line 5 from:
\\\
to:
\\\
Changed line 22 from:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like: \\

to:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like: \\-'

February 24, 2010, at 11:58 AM by 18.111.95.214 -
Changed lines 24-25 from:

b3Input(); this statement sets up pin b3 to read information from a switch

to:

b3Input(); this statement sets up pin b3 to read information from a switch\\\

Changed lines 30-31 from:

_delay_ms(1000);-'

to:

_delay_ms(1000); -'

February 24, 2010, at 11:57 AM by 18.111.95.214 -
Changed line 22 from:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like:

to:

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like: \\

Changed lines 24-25 from:

b3Input(); this statement sets up pin b3 to read information from a switch\\-'

to:

b3Input(); this statement sets up pin b3 to read information from a switch

Changed line 27 from:

'-This section is where the main action of our program takes place. In this piece of code we have 4 lines: \\\

to:

This section is where the main action of our program takes place. In this piece of code we have 4 lines: \\\

February 24, 2010, at 11:56 AM by 18.111.95.214 -
Changed lines 24-25 from:

b3Input(); this statement sets up pin b3 to read information from a switch

to:

b3Input(); this statement sets up pin b3 to read information from a switch\\-'

Changed line 27 from:

This section is where the main action of our program takes place. In this piece of code we have 4 lines: \\\

to:

'-This section is where the main action of our program takes place. In this piece of code we have 4 lines: \\\

February 24, 2010, at 11:55 AM by 18.111.95.214 -
Changed lines 21-25 from:

Identify pin b0 on the diagram. Notice that in addition to b0 there are b1, b2, b3, b4, and b5. We can use b1-b4 in our programs. We will not be using b5 in any of our programs. We need to do a special kind of programming to use b5.\\\

to:

Identify pin b0 on the diagram. Notice that in addition to b0 there are b1, b2, b3, b4, and b5. We can use b1-b4 in our programs. We will not be using b5 in any of our programs. We need to do a special kind of programming to use b5.

For every program that you create, you need to include a statement like b0Output() for every pin you would like to use to read information from a switch or to control an output device. Here's what those statements look like: b1Output(); this statement sets up pin b1 to control an output like a light or motor
b3Input(); this statement sets up pin b3 to read information from a switch

February 24, 2010, at 11:52 AM by 18.111.95.214 -
Changed line 10 from:

'-Comment Area\\

to:

'-Comments Area\\

Changed line 16 from:

Setup Area 1\\

to:

Setup Area 1\\

Changed line 18 from:

Setup Area 2\\

to:

Setup Area 2\\

Changed lines 21-22 from:

Main Action Area\\

to:

Identify pin b0 on the diagram. Notice that in addition to b0 there are b1, b2, b3, b4, and b5. We can use b1-b4 in our programs. We will not be using b5 in any of our programs. We need to do a special kind of programming to use b5.

Main Action Area\\

February 24, 2010, at 11:49 AM by 18.111.95.214 -
Changed line 10 from:

'-Comment Section\\

to:

'-Comment Area\\

Changed line 26 from:

_delay_ms(1000);\\\-'

to:

_delay_ms(1000);-'

February 24, 2010, at 11:48 AM by 18.111.95.214 -
Changed line 10 from:

Comment Section\\

to:

'-Comment Section\\

Changed lines 19-20 from:

This section is where we tell our ATtiny13 which legs we'll be using for which purpose. In our code the line b0Output() tells the ATtiny that an output (like an LED or a motor) will be attached to pin b0. Each pin on the ATtiny13 has a name like b0. To know which pin is which, you can refer to the pin diagram from the ATtiny's datasheet. Here's what that looks like: Attach: ATtiny13PinOut.png\\\

to:

This section is where we tell our ATtiny13 which legs we'll be using for which purpose. In our code the line b0Output() tells the ATtiny that an output (like an LED or a motor) will be attached to pin b0. Each pin on the ATtiny13 has a name like b0. To know which pin is which, you can refer to the pin diagram from the ATtiny's datasheet. Here's what that looks like:
\\\

Changed lines 22-26 from:

This section is were the main action of our program takes place. In this piece of code we have 4 lines: \\

to:

This section is where the main action of our program takes place. In this piece of code we have 4 lines:

b0High();
_delay_ms(1000);
b0Low();
_delay_ms(1000);\\\-'

February 24, 2010, at 11:46 AM by 18.111.95.214 -
Changed line 11 from:

At the top of the page there is a comment section that gives some basic information about the program. This section is ignored by the computer. It's just there to give us humans some information about the file. In general, a comment is a piece of text that is ignored by the computer. Comments can be anywhere in your program. There are two different ways to create comments: \\

to:

At the top of the page there is a comment section that gives some basic information about the program. This section is ignored by the computer. It's just there to give us humans some information about the file. In general, a comment is a piece of text that is ignored by the computer. Comments can be anywhere in your program. There are two different ways to create comments: \\\

Changed lines 16-24 from:
to:

Setup Area 1
This section is where we tell our program what other files it will need and set some basic parameters. We'll be ignoring this section for now.

Setup Area 2
This section is where we tell our ATtiny13 which legs we'll be using for which purpose. In our code the line b0Output() tells the ATtiny that an output (like an LED or a motor) will be attached to pin b0. Each pin on the ATtiny13 has a name like b0. To know which pin is which, you can refer to the pin diagram from the ATtiny's datasheet. Here's what that looks like: Attach: ATtiny13PinOut.png

Main Action Area
This section is were the main action of our program takes place. In this piece of code we have 4 lines:
\\

February 24, 2010, at 11:41 AM by 18.111.95.214 -
Changed lines 5-6 from:
to:


This program is written in the C programming language.
Changed lines 9-14 from:

\* Anything in between a slash and an asterik and then an asterik and
a slash, like this statement *\
OR
'\\ A sigle line of text that follow two slashes like this line.

to:


Comment Section
At the top of the page there is a comment section that gives some basic information about the program. This section is ignored by the computer. It's just there to give us humans some information about the file. In general, a comment is a piece of text that is ignored by the computer. Comments can be anywhere in your program. There are two different ways to create comments:
\* Anything in between a slash and an asterisk and then
an asterisk and a slash, like this statement is a comment *\

OR
\\ A sigle line of text that follows two slashes like this line is also a comment.

February 24, 2010, at 11:35 AM by 18.111.95.214 -
Changed line 11 from:
 \* purpleAnything in between a slash and an asterik and then an asterik and \\
to:

\* Anything in between a slash and an asterik and then an asterik and \\

Changed line 13 from:

'\\ purpleA sigle line of text that follow two slashes like this line.

to:

'\\ A sigle line of text that follow two slashes like this line.

February 24, 2010, at 11:34 AM by 18.111.95.214 -
Changed line 11 from:

purple \* Anything in between a slash and an asterik and then an asterik and \\

to:
 \* purpleAnything in between a slash and an asterik and then an asterik and \\
Changed line 13 from:

'\\ A sigle line of text that follow two slashes like this line.

to:

'\\ purpleA sigle line of text that follow two slashes like this line.

February 24, 2010, at 11:07 AM by 18.111.95.214 -
Added lines 10-13:

purple \* Anything in between a slash and an asterik and then an asterik and
a slash, like this statement *\ OR
'\\ A sigle line of text that follow two slashes like this line.

February 24, 2010, at 09:17 AM by 66.92.79.106 -
Changed line 12 from:
The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the for (;;) statement, it does what is inside the curly brackets "{" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top: \\\
to:
The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the "for (;;)" statement, it does what is inside the curly brackets "{" and "}" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top: \\\
February 24, 2010, at 09:15 AM by 66.92.79.106 -
Changed line 4 from:
Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor. Here's what my file looks like in the TextEdit application:
to:
Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor. Here's what my file looks like in the TextEdit application: \\\
Changed line 12 from:
The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the for (;;) statement, it does what is inside the curly brackets "{" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top:
to:
The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the for (;;) statement, it does what is inside the curly brackets "{" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top: \\\
February 24, 2010, at 09:15 AM by 66.92.79.106 -
Changed lines 4-5 from:
Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor.
to:
Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor. Here's what my file looks like in the TextEdit application:
Changed line 8 from:
to:
February 24, 2010, at 09:13 AM by 66.92.79.106 -
Changed lines 7-9 from:

Attach: AVRCodeRegions.jpg

to:
Changed lines 11-12 from:
The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the for (;;) statement, it does what is inside the curly brackets "{" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top:

Attach: AVRCodeExecution.jpg

to:
The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the for (;;) statement, it does what is inside the curly brackets "{" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top:
February 24, 2010, at 09:13 AM by 66.92.79.106 -
Added lines 1-13:

AVR Programming Tutorial: Writing Programs

0. Open the blink.c program file.

Browse to the NewTextilesAVR directory, open the code folder and double click the blink.c file to open it in a text editor.

1. The program is broken up in to a few different regions. Here are the ones we care about: Attach: AVRCodeRegions.jpg

2. Understanding program structure.

The program is a list of instructions that tell the microcontroller (our ATtiny13) what to do. The ATtiny13 follows the instructions line by line, starting from the top and moving to the bottom. However, when it reaches the for (;;) statement, it does what is inside the curly brackets "{" after the for statement over and over again forever. When it reaches the closing curly bracket "}'" it jumps up to the opening curly bracket and begins again from the top:

Attach: AVRCodeExecution.jpg