MobFinder Arduino tips and
int inByte = 0; // incoming serial byte
boolean isReadingData = 0; // kick off loop
const int ledPin = 13; // the number of the LED pin
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop()
{
// read the USB input
inByte = Serial.read(); // read a character coming from the serial port
if (inByte == 'A')
{
Serial.print('G', BYTE); // write GO to the serial port
Serial.print('O', BYTE);
Serial.print('\n', BYTE);
isReadingData = true;
digitalWrite(ledPin, HIGH); // turn on the led
}
if (inByte == 'B')
{
Serial.print('S', BYTE); // write STOP to the serial port
Serial.print('T', BYTE);
Serial.print('O', BYTE);
Serial.print('P', BYTE);
Serial.print('\n', BYTE);
isReadingData = false;
digitalWrite(ledPin, LOW); // turn off the led
}}
0 comments:
Post a Comment