NerdKits - electronics education for a digital generation  
Did you know that multiple MOSFETs can be used in parallel to switch bigger currents on and off? Learn more...

You are not logged in. [log in]

Microcontroller Programming » Simple "Hello World" Using UART

August 15, 2009
by Nerdful_com

Here is an AVR "Hello World" demonstration that writes "Hello World" to your PC VIA serial to USB every 1 second (open hyper terminal to see).

/* 
Made by www.Nerdful.com
Prints HELLO WORLD to the PC VIA serial RS232 (terminal)
*/

#define F_CPU 14745600
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "../libnerdkits/delay.h"
#include "../libnerdkits/uart.h"

int main() {
uart_init();
FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
stdin = stdout = &uart_stream;
while(1) {
printf_P(PSTR("HELLO WORLD from www.Nerdful.com\r\n"));
delay_ms(1000);
} 
return 0;
}
March 20, 2010
by brian

What pins does it output the serial data to?

March 20, 2010
by mongo

It returns the test through the USB adapter to the computer.

March 20, 2010
by mongo

ummm TEXT - not test...DUHH, Dyslexic fingers.

March 20, 2010
by brian

Hmm...doesn't seem to be working for me. Maybe I did something wrong?

March 21, 2010
by brian

Nevermind - the code works fine on the pins 2/3 with the included serial adapter...you just have to remember to set the baud rate to 115200 in PuTTY ;)

Post a Reply

Please log in to post a reply.