Hello
I am trying to have a serial communication between two micro controllers (mega and Uno) where the Uno micro controller will send a signal when sensor is touched in order to move a servo motor connected to the Mega.
I am trying to send a Char from the Uno32 to it. but the mega is not receiving neither the Receiver led is blinking.
These are the serial block in the code:
MEGA: Receiver
if ( Serial1.available())
{
sensorSerialData= Serial1.read();
val= Serial1.parseInt();
if (val== 3){
int j=9;
while(j!=0){
myservo1.write(170);
myservo2.write(0);
delay(400);
myservo1.write(90);
myservo2.write(90);
j--;
}
Uno:Transmitter:
if(sensorvalue4 == HIGH )
{
Serial1.write(3);
digitalWrite(laughing, LOW);
delay(500);
}
plz help where do you think is the error?
I don't know anything about the Chipkit Uno32 so let's assume you have that part right.
Have you the connections correct ? Rx to Tx, Tx to Rx and GND to GND.
Look at the examples in serial input basics for simple reliable ways to receive data.
And please use the code button when posting code
...R
Delta_G:
sensorSerialData= Serial1.read(); // this line gets the 3 out of the buffer
val= Serial1.parseInt(); // Now there's nothing left for this one to read
Since you're using write to send the 3 raw and not ascii, I don't think parseInt is what you want. Just stick with the one in sensorSerialData
Thanks for your reply appreciate it
however i have tried this one before, i mean sticking with only
sensorSerialData= Serial1.read();
still no luck
When i send an integer to the mega does it receive it as integer or do i have to convert it there as well?