mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 11:26:25 +02:00
[ES] Fixed potential error with loop
Signed-óff-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -88,25 +88,27 @@ void setup() {
|
||||
*/
|
||||
void loop() {
|
||||
if (Serial.available() > 0) {
|
||||
char command[8];
|
||||
char currentChar;
|
||||
int i = 0;
|
||||
bool readable = true;
|
||||
while (readable) {
|
||||
currentChar = Serial.read();
|
||||
readable = (currentChar != -1);
|
||||
command[i] = currentChar;
|
||||
i++;
|
||||
}
|
||||
command[i] = '\0';
|
||||
|
||||
if (strcmp(command, "LED_on") == 0) {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
else {
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
Serial.println(command);
|
||||
char command[8];
|
||||
char currentChar;
|
||||
int i = 0;
|
||||
bool readable = true;
|
||||
while (readable) {
|
||||
currentChar = Serial.read();
|
||||
readable = (currentChar != -1);
|
||||
if (readable) {
|
||||
command[i] = currentChar;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
command[i] = '\0';
|
||||
|
||||
if (strcmp(command, "LED_on") == 0) {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
else {
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
Serial.println(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user