BanScie CT10 Bug Fix Exercise (Bug A) — Arduino Uno simulation

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

Components

Sketch code

/*
 * Bug A: blinkLED should blink 3 times and stop.
 * But the LED keeps blinking forever!
 */

const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  blinkLED(200, 3);
  delay(3000);
}

void blinkLED(int delayMs, int count) {
  int i = 0;
  while (i < count) {
    digitalWrite(ledPin, HIGH);
    delay(delayMs);
    digitalWrite(ledPin, LOW);
    delay(delayMs);
  }
  Serial.println("Done!");
}

More projects by christopherraegigantana