Connecting two ATMEGA88 chips RS232

I need help in sending date from a master and slave Atmel88 chip. I have completed the RS232 already and it works but I can only send one Bit. How can I send 8 I/O digital bits and 6 analogue bits so the slave Atmel can understand it?

Here is the code that works with one bit.

/*

  • Program for check analog and digital input for joystick
    Swap Jumper Number 9 Because we need to use this pin for input*
  • Function : Read Analog and Digital to Display to RS232
    */
    #define ledPin 13
    void setup() //Setup Function
    {
    Serial.begin(19200); //Initial RS232 Baud = 19200
    Serial.println("Please enter text");
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin,LOW);
    }

void loop() //Main Function
{

if (Serial.available() > 0)
{
int var = Serial.read();
if (var ==0x31)
{
digitalWrite(ledPin,HIGH);
}else if (var !=0x31)
{
digitalWrite(ledPin,LOW);
}
}
}

Here is the slave code.

  • Program for check analog and digital input for joystick
    Swap Jumper Number 9 Because we need to use this pin for input*
  • Function : Read Analog and Digital to Display to RS232
    */
    #define ledPin 13
    void setup() //Setup Function
    {
    Serial.begin(19200); //Initial RS232 Baud = 19200
    Serial.println("Please enter text");
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin,LOW);
    }

void loop() //Main Function
{

if (Serial.available() > 0)
{
int var = Serial.read();
if (var ==0x31)
{
digitalWrite(ledPin,HIGH);
}else if (var !=0x31)
{
digitalWrite(ledPin,LOW);
}
}
}

As said this code works. But how do I send 8 I/O digital pin data and 6 analogue so the other processor understands it?

Thanks

Forgive me for stating the obvious, but aren't those two sketches identical?

if (var ==0x31)
   {
     digitalWrite(ledPin,HIGH);
   }else if (var !=0x31)

Two things here:

  1. Not everyone carries an ASCII chart around with them (I do, but I'm just weird), so "if (var =='1')" is much easier to read.
  2. If you've tested "var" and it isn't ASCII '1', then there's no need to test it again to see if it still isn't ASCII '1'.
    If you've tested "var" and it isn't

No one is for the reciever Atmel and one is for the Transmitter. These work perfectly. My question was how do I send 8 digital I/O commands and 6 analogue commands via RS232.

Cheers

No one is for the reciever Atmel and one is for the Transmitter

So they're not identical?

I'd define an unambiguous protocol - maybe have a look at the Firmata sources.

Sorry,

Yes they are idntical. This is the reciever board which puts an out high to the LED.

The transmiter reads a switch input and and sends a 1 or 0 to the rs232 port.

What I want to do is send 8 digital I/O and 6 analogue values. At the moment I can only send a one or zero succesfully,

Take care.