The AVR is a Modified Harvard architecture 8-bit RISC single chip microcontroller (µC) which was developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to One-Time Programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

One Way Traffic Light Code

August 9th, 2009

I am learning how to make C code better & cleaner. Also notice how the delay has an underscore before it now as I updated my makefile not to have any of libnerdkits includes (I never did that with the previous codes I was trying to not use Nerdkit includes).  It seems that skipping any NerdKit files gives us pure AVR programming say that was made using AVR Studio (I can find more source codes now), making this kit a complete and open source development board. I just wonder if I was to say start a scrolling LED clock as a full retail product (fully assembled), would I be allowed to buy my own cheaper MCUs without bootloader and use NerdKit's bootloader without owing them money on each unit?

Here's code for a 1 way traffic light with some bit:

#include <avr/io.h>
#include <avr/delay.h>
 /*
Comments by www.nerdful.com
Here we are woking on a 3bit (ex 0b110)
We use a 6bit (ex 0b000111) to activated the PortC pins 23-25 (pc0 to pc2) and disablepins 26-28 (pc3 to pc5)
0z mean on, 1z mean off
*/
main()
{
DDRC = 0b000111; // enable pins 23-25 of portc and disable pins 26-28 - out of the 6bit pattern that covers all port C, 1st is on, 2nd is on, 3rd is on, 4th is off, 5th is off, 6th is off
while(1)
{
PORTC = 0b110; // turn on PC0 pin 23 (green) - out of the 3bit, 1st 2 are off, last is on
_delay_ms(10000);
PORTC = 0b101; // turn on PC1 pin 24 (orange) - out of the 3bit pattern, 1st is off, 2nd is on, 3rd is off
_delay_ms(4000);
PORTC = 0b011; // turn on PC2 pin 25 (red) - out of the 3bit pattern, 1st is on, 2nd is off, 3rd is off
_delay_ms(10000);
}
}



Comments:

No comments yet. You could be the first person to comment!

Make A Comment:

Name:

Your message/comment:

characters left.
For AVR codes, use my PasteBin & post link.

Prove you are human (enter the text seen in image):


Make your own email signatures like this @ www.text2logo.com


Free image widgets HERE.