Hello All!
My name is Connor, I am a hobbyist electrician slowly making me way into deeper waters as I prepare for pursuing my bachelors in Electrical Engineering. I have a basic understanding of Arduino C, but I am having trouble navigating some of the syntax. On to my situation! I am utilizing an ESP32CAM with a QRCodeReader library (code posted below). Once it receives any valid QRcode, it outputs the "payload" (the string that makes up the QRcode) to the serial monitor and then turns on the LED at Pin 12. My question is: Can I use the serial monitor's output to make the LED at Pin 12 only activate when a certain code or "payload" is received? I.E. ESP reads "1234", Serial Monitor outputs "1234", Pin 12 activates, but if ESP reads "4321" and Serial Monitor outputs "4321" Pin 12 does not activate. The goal is eventually to have 3 separate codes that activate their own LEDs. Thank you in advance for any help!
ESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER);
void onQrCodeTask(void *pvParameters)
{
struct QRCodeData qrCodeData;
while (true)
{
if (reader.receiveQrCode(&qrCodeData, 100))
{
Serial.println("Found QRCode");
if (qrCodeData.valid)
{
Serial.print("Payload: ");
Serial.println((const char *)qrCodeData.payload);
digitalWrite(12, HIGH);
}
else
{
Serial.print("Invalid: ");
Serial.println((const char *)qrCodeData.payload);
}
}
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
void setup()
{
Serial.begin(115200);
Serial.println();
pinMode(12,OUTPUT);
reader.setup();
Serial.println("Setup QRCode Reader");
reader.beginOnCore(1);
Serial.println("Begin on Core 1");
xTaskCreate(onQrCodeTask, "onQrCode", 4 * 1024, NULL, 4, NULL);
}
void loop()
{
delay(100);
}