Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

/*

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

This sequence should repeat indefinitely.


*/
#include <Adafruit_NeoPixel.h> // Include the NeoPixel library

#define PIN 8 // Pick the pin on the Adafruit CPE that the LED is connected to (in this case, pin 8)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, PIN, NEO_GRB + NEO_KHZ800);

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

// Green chasing pattern


for (int i = 0; i <= 9; i++) {
strip.setPixelColor(i, 0, 255, 0);
strip.show();
// delay(50); // CODE ERROR: Incorrect delay
delay(100); // Correct code
}
//delay(5000); // CODE ERROR: Incorrect delay
delay(1000); // Correct code

// Blue chasing pattern


for (int i = 0; i <= 9; i++) {
strip.setPixelColor(i, 0, 0, 255);
strip.show();
//delay(600) // CODE ERROR: Missing semicolon
delay(100); // Correct code
}
//delay(50); // CODE ERROR: Incorrect delay
delay(1000); // Correct code
}

You might also like