NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Blinking LED - Simplest Project I Could Come Up With

August 07, 2009
by Nerdful_com
Nerdful_com's Avatar

In the code I will provide, you need to take a LED neg/grnd and put it on pin 25 of the MCU (PC2) and the positive (longer wire on LED) goes to the positive rail for power. You should also notice that the code uses no include files from libnerdkit (I needed to see AVR in action without changed files by NerdKit), all include files are provided by WinAVR. The code below I tested with the NerdKit (no LCD hooked up).

/* 
I'm not a nerd, just nerdful!
www.nerdful.com
*/

#include <avr/io.h>
#include <avr/delay.h>
void sleep(uint8_t millisec)
{
while(millisec)
{
delay_ms(1);
millisec--;
}
}
main()
{
DDRC |=1<<PC2;
 while(1)
{
PORTC &= ~(1<<PC2);
sleep(100);
PORTC |=(1<<PC2);
sleep(100);
}
}
August 07, 2009
by Nerdful_com
Nerdful_com's Avatar

I could have made it simpler by just turning on the light (no flashing), but I needed some thrilling action!

Post a Reply

Please log in to post a reply.

Did you know that one NerdKits customer discovered that his hamster ran several miles in a night using his kit and a Hall-effect sensor? Learn more...