NANO — Arduino Nano simulation

An interactive Arduino Nano circuit simulation you can run free in your browser on Velxio, by mark30805740.

Components

Sketch code

const int LED_PIN = 2;
String buff = "";

void setup() {
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

  Serial.begin(9600);
  Serial.println("Server Started");
  Serial.println("Waiting for Client data...");
}

void loop() {
  while (Serial.available() > 0) {
    char incomingChar = Serial.read();

    if (incomingChar == '\n') {
      buff.trim();

      if (buff.length() > 0) {
        Serial.print("Received from Client: ");
        Serial.println(buff);

        if (buff == "START") {
          digitalWrite(LED_PIN, HIGH);
          Serial.println("LED Status: ON");
        }
        else if (buff == "STOP") {
          digitalWrite(LED_PIN, LOW);
          Serial.println("LED Status: OFF");
        }
        else {
          Serial.println("Unknown Command");
        }
      }

      buff = "";
    }
    else {
      buff += incomingChar;
    }
  }
}

More projects by mark30805740