unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 500; // interval at which to blink (milliseconds)
const int led = 12; // the number of the LED pin
int ledState = HIGH; // ledState used to set the LED
boolean state = false;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
for (int thisPin = 12; thisPin < 12; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
if (Serial.available()) {
int serialinput = Serial.read();
switch (serialinput) {
// Your existing case statements...
case 'a':
digitalWrite(led, HIGH);
state = true;
break;
case 'b':
Serial.print("NUMBER 2");
Serial.println(" ");
break;
case 'c':
Serial.print("NUMBER 3");
Serial.println(" ");
break;
default:
for (int thisPin = 12; thisPin < 12; thisPin++) {
digitalWrite(thisPin, HIGH);
}
}
}
if (state == true) {
Blink();
} else {
digitalWrite(led, HIGH); // check to make sure it's off incase it was still on
}
}
void Blink() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == HIGH) {
ledState = LOW;
} else {
ledState = HIGH;
}
digitalWrite(led, ledState);
}
}