You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#include <SoftwareSerial.h>
|
|
SoftwareSerial mySerial(10, 11); // RX, TX
|
|
|
|
/* Use a variable called byteRead to temporarily store
|
|
the data coming from the computer */
|
|
|
|
byte byteRead;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
mySerial.begin(9600);
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
}
|
|
|
|
void loop() {
|
|
char a[8];
|
|
/* check if data has been sent from the computer: */
|
|
if (Serial.available())
|
|
{
|
|
/* read the most recent byte */
|
|
byteRead = Serial.read();
|
|
//a[0] = atoi(byteRead);
|
|
//a[1] = atoi(byteRead);
|
|
Serial.print("rushin\r\n");
|
|
/*ECHO the value that was read, back to the serial port. */
|
|
if(byteRead == 0x61)
|
|
{
|
|
digitalWrite(LED_BUILTIN, HIGH);
|
|
Serial.write(byteRead);
|
|
}
|
|
}
|
|
|
|
if (mySerial.available())
|
|
{
|
|
/* read the most recent byte */
|
|
byteRead = mySerial.read();
|
|
//a[0] = atoi(byteRead);
|
|
// a[1] = atoi(byteRead);
|
|
mySerial.print("rushin\r\n");
|
|
/*ECHO the value that was read, back to the serial port. */
|
|
if(byteRead == 0x61)
|
|
{
|
|
digitalWrite(LED_BUILTIN, HIGH);
|
|
mySerial.write(byteRead);
|
|
}
|
|
}
|
|
}
|