Étape 3: Échantillon Arduino Code
#include « Arduino.h »#define DEBUG
SoftwareSerial mySerial (5,6) ;
unsigned char incomingByte ;
Sub sendIdentifyCmd ()
{
mySerial.write (0x7c) ;
mySerial.write (0xff) ;
mySerial.write (0xff) ;
mySerial.write (0 x 01) ;
mySerial.write (0 x 08) ;
mySerial.write (0x7d) ;
#ifdef DEBUG
Serial.Print (0x7c) ;
Serial.Print (0xff) ;
Serial.Print (0xff) ;
Serial.Print (0 x 01) ;
Serial.Print (0 x 08) ;
Serial.Print (0x7d) ;
Serial.println () ;
#endif
}
installation Sub ()
{
Serial.Begin (9600) ;
mySerial.begin (9600) ;
Serial.println ("commencer la série initiale! \n") ;
}
void loop ()
{
sendIdentifyCmd () ;
retard (2) ;
while (mySerial.available () > 0)
{
incomingByte=mySerial.read () ;
Serial.Print (incomingByte, HEX) ;
Serial.Print (' ') ;
}
Serial.println () ;
retarder (1000) ;
}