Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char commandC;
- String command;
- void setup() {
- Serial.begin(115200);
- Serial1.begin(115200);
- // Wait for PuTTY
- while(!Serial1);
- delay(1000);
- Serial1.println("");
- Serial1.println("\t\tSuccessfully connected with arduino!");
- Serial1.println("");
- Serial1.println("");
- }
- void loop() {
- while(Serial.available()) {
- delay(5);
- Serial1.write(Serial.read());
- }
- while(Serial1.available()) {
- commandC = Serial1.read();
- command = String(command + commandC);
- Serial.print("Current char: ");
- Serial.println(commandC);
- Serial.println();
- Serial.print("Command: ");
- Serial.println(command);
- if(command == "rLed") {
- digitalWrite(9, HIGH);
- delay(1500);
- digitalWrite(9, LOW);
- commandC = '\0';
- command = "\0";
- } else if(command == "gLed") {
- digitalWrite(8, HIGH);
- delay(1500);
- digitalWrite(8, LOW);
- } else if(command == "bLed") {
- digitalWrite(7, HIGH);
- delay(1500);
- digitalWrite(7, LOW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement