ATMega8

This tutorial is about communication between the PC and an AVR microprocessor over serial, using a very simple arduino sketch, and a MAX232 chip.

In this tutorial we will need the following parts:

An AVR microprocessor, in this case I used the ATMega8.

A MAX232 chip, or you can use the kit provided by RAM electronics for simplicity, and it is not expensive.

Capacitors

First let's make the serial communication circuit.

Once this circuit is complete, you can hook it to the serial port of your PC, and you're on.

Most of the notebooks these days don't have a serial port, so you might want to buy a USB to Serial adapter.

you can test it simply by closing both pins 11 (TX) and 12 (RX) together in a loop back,and connect using putty or hyper terminal, or any software you like.

When it is connected, type anything in the window, and it will be sent back to you, this means it is working.

Then we insert the ATMega in the breadboard, and burn a simple code to the chip, you can check out this previous tutorial, to help you using the Arduino IDE to program your ATMega.

Here is the Arduino sketch I used:

int ReceivedByte = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) {
// get incoming byte:
ReceivedByte = Serial.read();
Serial.print("I received: ");
Serial.println(ReceivedByte, DEC);
}
}

Now we connect the TX pin on the MAX232 to the RX pin on the ATMega, and the RX pin on the MAX232 to the TX pin on the ATMega, and you're done!!

As you did in the previous step, connect it to the PC and type any letter, it will be sent back as "I received: A".