finished implementation

master
BodgeMaster 2021-05-04 21:27:34 +02:00
parent 5a82d0d988
commit 5cc71d5ff5
1 changed files with 67 additions and 30 deletions

View File

@ -108,6 +108,7 @@ void runCommand(){
String mode; String mode;
uint8_t pin; uint8_t pin;
String state; String state;
uint8_t pwmState;
switch ((char)command) { switch ((char)command) {
case 'R': // run setup() again case 'R': // run setup() again
Serial.print("R"); Serial.print("R");
@ -223,6 +224,43 @@ void runCommand(){
Serial.print("e"); Serial.print("e");
} }
return; return;
case 'p': // set a pwm pin
Serial.print("p");
pin = waitForSerialInput(2).toInt();
pwmState = waitForSerialInput(3).toInt();
if (digitalPinHasPWM(pin)) {
analogWrite(pin, pwmState);
Serial.print("s");
} else {
Serial.print("e");
}
return;
case 't': // toggle a pin
Serial.print("t");
if (toggleState(waitForSerialInput(2).toInt())==UNKNOWN_PIN) Serial.print("e");
else Serial.print("s");
return;
case 'l':
Serial.print("l");
state = waitForSerialInput(1);
if (state=="h") {
digitalWrite(LED_BUILTIN, HIGH);
Serial.print("s");
} else if (state=="l") {
digitalWrite(LED_BUILTIN, LOW);
Serial.print("s");
} else if (state=="t") {
toggleState(LED_BUILTIN);
Serial.print("s");
} else {
Serial.print("e");
}
return;
case 'q':
Serial.print("qs");
while (true) {
}
return;
default: default:
Serial.print("e"); Serial.print("e");
} }
@ -247,7 +285,6 @@ void setup(){
Serial.read(); Serial.read();
} }
Serial.print("s\r\n"); Serial.print("s\r\n");
// testing
} }
void loop(){ void loop(){