In many tutorials you can see this method to send a byte tipe variable:
buff[0]=0x80; //start byte
buff[1]=0x01; //device id
buff[2]=0x04; //command number
for(int i=0;i<3;i++)
{
Serial.print(buff[i],BYTE);
}
If your are using the arduino IDE 1.0 or above that code will return error, because BYTE is no longer supported, instead, the solution is using "write"
Serial.print(buff[i],BYTE); Is trying to send the array "buff" by serial in a byte mode.
The new model accepted by Arduino IDE is using Serial.write(buff[i])
Serial.write(buff[i]); Already send in byte mode the variable "buff" so you don't have to specify BYTE anymore.
Reference: http://arduino.cc/es/Serial/Write // http://arduino.cc/es/Serial/Print
No hay comentarios:
Publicar un comentario