Professional Documents
Culture Documents
Fixed - Adafruit Broken Code
Fixed - Adafruit Broken Code
Written by Brandon Watson for the AI & Arduino Coding Assignment in CTCH 110 at the University of
Regina.
The following code is designed to use the 10 onboard RGB LEDS on an Adafruit Circuit Playground
Express in a certain sequence. The sequence is:
Red - chasing pattern (delay between pixel 100 miliseconds) from LED 1 to 10 until all are red
Pause - keep all LEDs red for 1 second
Green - change LEDs from red to green in a chasing pattern (delay between pixel 100 miliseconds) from
LED 1 to 10 until all are green
Pause - keep all LEDs green for 1 second
Blue - change LEDs from green to blue in a chasing pattern (delay between pixel 100 miliseconds) from
LED 1 to 10 until all are blue
Pause - keep all LEDs blue for 1 second
return to start
#define PIN 8 // Pick the pin on the Adafruit CPE that the LED is connected to (in this case, pin 8)
void setup() {
strip.begin(); // Initialize the LED pixels
strip.show(); // Initialize the pixels to ’off’
//strip.setBrightness(25) // CODE ERROR: Missing semicolon
strip.setBrightness(25); // Correct code
}
void loop() {
// Red chasing pattern
for (int i = 0; i <= 9; i++) {
strip.setPixelColor(i, 255, 0, 0);
strip.show();
// delay(500); // CODE ERROR: Incorrect delay
delay(100); // Correct code
}
//delay(2000); // CODE ERROR: Incorrect delay
delay(1000); // Correct code