Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #define NEW_PIXEL_PIN 7
- #define NUMPIXELS 48 // number of neo pixels
- char state = '2';
- Adafruit_NeoPixel pixels(NUMPIXELS, NEW_PIXEL_PIN, NEO_GRB + NEO_KHZ800);
- void setup() {
- Serial.begin(9600);
- pixels.begin();
- pixels.setBrightness(50);
- pixels.clear();
- }
- void loop() {
- if (Serial.available() > 0) {
- state = Serial.read();
- }
- if (state == '0') {
- Serial.println("Code is incorrect!");
- state = '2';
- set_neo_pixel(false);
- set_neo_pixel(false);
- set_neo_pixel(false);
- } else if (state == '1') {
- Serial.println("Code is correct!");
- state = '2';
- set_neo_pixel(true);
- // =========================
- // Implement the follwing lines according to instuctions
- // =========================
- }
- }
- void set_neo_pixel(bool debug) {
- if (debug) {
- pixels.fill(pixels.Color(0, 0, 255), 0, 48);
- } else {
- pixels.fill(pixels.Color(255, 0, 0), 0, 48);
- }
- pixels.show();
- delay(500);
- pixels.clear();
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement