Hey Guys,
This seems like a very simple task, but for some reason I am having a terribly hard time with it. I am trying to initiate communication between 2 Arduinos. The master has to read an analog value from the slave, and then, based on that value, send a signal to the slave that will trip a relay. This is the code that I have already, but it is not working. Any help would be greatly appreciated.
Thanks a lot!
Greg
/**
Serial communication between 2 arduinos - Master Code
**/
int switchPin = 13;
int rxByte=0;
char rx_string[5];
int string_pos=0;
void setup()
{
Serial.begin (9600);
pinMode(switchPin, OUTPUT);
for(int i=0; i<6;i++)
{
rx_string*=0;*
- }*
}
void read_serial()
{
-
rxByte=Serial.read();*
-
if((rxByte>=0) && (rxByte<=9))*
-
{*
-
rx_string[string_pos]=rxByte;*
-
string_pos++;*
-
}*
-
if(inByte==5)*
-
{*
-
Serial.println(rx_string);*
-
for (int u=0; u<6: u++)*
-
{*
-
rx_string=0;*
}
string_pos=0;
}
}
void loop()
{
while(Serial.available())
{
read_serial();
}
}