Skip to content

Instantly share code, notes, and snippets.

@headHUB
Created July 28, 2017 20:01
Show Gist options
  • Save headHUB/46c278b17d148ecb790983b9c6a3e6e2 to your computer and use it in GitHub Desktop.
Save headHUB/46c278b17d148ecb790983b9c6a3e6e2 to your computer and use it in GitHub Desktop.
const int ledPin = 12;
void setup(){
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop(){
if (Serial.available()) {
light(Serial.read() – ‘0’);
}
delay(500);
}
void light(int n){
for (int i = 0; i < n; i++) {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment