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