Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Zigbee arduino -serial communication help

Status
Not open for further replies.
I am workng on this project
https://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand/

code : https://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand/step6/CODE/

Although the code is there in this link .but i made a completly different code...beacuse using map was not giving precise results so i made mapping function for each flex seperatly.In this code(given in link above) if(Serial.available() >=5) is used...I am working on serial communication for the first time..so I am not able to understand how serial communication using zigbee occur.. Does it send data in string ?
I tried sending 5 numbers by using serial.available.."152 689 356 123 124"
then it printed 1 5 2 6 8. so i think data in string form is send...
here is my code (attached herewith)
I am not using default rx tx pin here....but using 0 and 1 as rx tx also give the same result...
Pleas help me out with what is wrong with this code..(random data is received by this code)
 

Attachments

  • rcv1.ino
    1.2 KB · Views: 313
  • send1.ino
    1.4 KB · Views: 313
Well i was hoping for solution...but i solved it by myself..so here it is.
if (Serial.available() > 2) // for 3 digit number...if 4 didgit number then serial.avaialable()>3
{
// read the incoming byte:
incomingByte=0;
x=0;
incomingByte = Serial.read();
x= (incomingByte-48)*100; // to convert ascii value to integer digit
if (x>=899) // two digit number 24 is send as 900 + 24 =924
x=x-900;
// Serial.println(incomingByte);
incomingByte = Serial.read();
x=x+((incomingByte-48)*10); // string to int conversion
// Serial.println(incomingByte);
incomingByte = Serial.read();
//Serial.println(incomingByte);
x=x+incomingByte-48;
s1=x;
Serial.println(s1);
//myservo1.write(s1);
}
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top