The below sketch works unless the commented out lines are included as well. All of the commented lines are to program a WS2812 LED. How can that be resolved?
#include <Wire.h>
#include "SparkFun_Qwiic_Rfid.h"
#include <SparkFun_Qwiic_OLED.h>
#include "SparkFun_Qwiic_Keypad_Arduino_Library.h"
#include <Servo.h>
#include <FastLED.h>
#define RFID_ADDR 0x13
#define NUM_LEDS 1
#define LED_DATA_PIN 7
const int intPin = 3;
Qwiic_Rfid myRfid(RFID_ADDR);
QwiicMicroOLED myOLED;
KEYPAD keypad;
Servo servo;
//CRGB leds[NUM_LEDS];
String tag;
String msg = "";
int x0, y0;
String passcode = "1111";
String currentEntry = "";
char button = "na";
int photoresistor = A0;
int photoresistorState;
bool checkForPhotoresistor = false;
void setup() {
delay(1000);
Wire.begin();
Serial.begin(9600);
if(myRfid.begin()) Serial.println("Ready to scan some tags!");
else Serial.println("Could not communicate with the Qwiic RFID Reader!!!");
pinMode(intPin, INPUT_PULLUP);
delay(1000);
if (myOLED.begin() == false) {
Serial.println("OLED begin failed. Freezing...");
while (true)
;
}
if (keypad.begin() == false) {
Serial.println("Keypad does not appear to be connected. Please check wiring. Freezing...");
while (1);
}
servo.attach(5);
pinMode(photoresistor, INPUT);
delay(1000);
//FastLED.addLeds<WS2812, LED_DATA_PIN, RGB>(leds, NUM_LEDS);
delay(1000);
//leds[0] = CRGB::Red;
//FastLED.show();
delay(1000);
servo.write(150);
}
void loop() {
keypad.updateFIFO(); // necessary for keypad to pull button from stack to readable register
button = keypad.getButton();
//Serial.println(button);
if (button != "na" && button != 0) {
currentEntry += button;
myOLED.text(0, 0, currentEntry, 1);
myOLED.display();
}
if (digitalRead(intPin) == LOW) {
tag = myRfid.getTag();
Serial.println(tag);
}
if (tag == "5809121824578" || currentEntry == passcode) {
myOLED.erase();
delay(1000);
//leds[0] = CRGB::Green;
//FastLED.show();
msg = "Access Granted";
x0 = (myOLED.getWidth() - myOLED.getStringWidth(msg)) / 2;
// starting y position - screen height minus string height / 2
y0 = (myOLED.getHeight() - myOLED.getStringHeight(msg)) / 2;
myOLED.text(0, 0, msg, 1);
myOLED.display();
servo.write(30);
delay(1000);
checkForPhotoresistor = true;
} else {
myOLED.erase();
}
while (checkForPhotoresistor) {
photoresistorState = analogRead(photoresistor);
Serial.println(photoresistorState);
if (photoresistorState < 200) {
msg = "";
delay(2000);
servo.write(150);
myOLED.erase();
myOLED.display();
//leds[0] = CRGB::Red;
//FastLED.show();
}
}
}