Hi every one,
I use UM6 with Arduino mega ADK. Ilike to read a packet from UM6 sensor, so I start with reading the header snp.
I use serial port1. the UM6 datasheet is here : http://www.chrobotics.com/docs/UM6_datasheet.pdf
My code return "n wasn't found" , so I can't find n just after the s caracter.This is my code :
//UM6 is in broadcast mode with baudrate 19200
//this proram try to find a correct header "snp"
byte data[63];
int n = 0;
void setup(){
Serial.begin(19200);
Serial1.begin(19200);
}
void loop()
{
n = Serial1.available();
if (n == 63){
//s'il existe des données venant de l'UM6, on les copie dans data
- for (byte i=0; i < n; i++){*
_ data = Serial1.read();_
* }*
* //on teste s'il existe s n p dans ce tableau data*
* for (byte i=0; i < n-1; i++){*
_ if (data == 's')
* {
if (data[i+1] == 'n')
{
if (data[i+2] == 'p')
{
Serial.println ("snp is found");
}
else Serial.println ("p wasn't found");
}
else Serial.println ("n wasn't found");
}
}
//le test de snp est terminé*
* }
} *_