-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple test that only looks at the pins, no extra guff - just to prov…
…e pin usage
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#define RX_PIN 19 | ||
#define TX_PIN 23 | ||
#define DIGITAL_PIN 18 | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
// put your setup code here, to run once: | ||
Serial2.begin(115200, SERIAL_8N1,RX_PIN,TX_PIN); | ||
pinMode(DIGITAL_PIN, INPUT); | ||
Serial.println("Setup Complete"); | ||
} | ||
|
||
String tmp; | ||
bool digitalState; | ||
void loop() { | ||
digitalState = digitalRead(DIGITAL_PIN); | ||
if (Serial2.available() > 0) { | ||
size_t len = Serial2.available(); | ||
// Serial.printf("%u %s\n", len, (String) digitalState); | ||
uint8_t buf[len]; | ||
Serial2.read(buf, len); | ||
// handleBytes(buf, len); | ||
buildString(buf, len); | ||
} | ||
|
||
if(digitalState == LOW) { | ||
if(tmp != "") { | ||
Serial.print("tmp = "); | ||
Serial.println(tmp); | ||
tmp = ""; | ||
} | ||
} | ||
|
||
} | ||
|
||
void buildString(uint8_t buf[], size_t len) { | ||
for (int i = 0; i < len; i++) { | ||
if (buf[i] < 0x10) { | ||
tmp += '0'; | ||
} | ||
tmp += String(buf[i], HEX); | ||
} | ||
} |