Unqualified-id error - attempting to get neopixel program running for a christmas gift

Salutations!

First let me start by saying I am fairly new to coding on arduino - I originally took filler programming class back in college and they only taught us cobolt... which from what I understand is a next to useless language today.

To preface this project, it is supposed to control neopixel leds to activate on a RFID tag. When activated it should spin LED's counter clockwise green with increasing speed before lighting the whole thing solid for a few seconds, then turn off and go to a slow tracing spin of white LED's until reactivated. If this sounds familiar its because I'm trying to mimic the activity of a Disney World magic band reader since my sister is a Disneyholic and figured it'd be awesome to make this for her for Christmas.

I originally got most of the code from Dominick Civitano on github. I've been trying to modify it to make it more appropriate for what I am looking for, including adding more LED control and the custom RFID tags (which may need to be looked at too since I'm trying to use several). The coding I added to have the white LED trace is toward the bottom before the loop void() as this is where I suspected to put it. However I am getting a unqualified-id before '{' token error despite seeing proper open and close amounts.
The error is located in this statement:

pixels.setPixelColor(41, pixels.Color(0,0,0));
 pixels.show();
}

{//idle white LED circling
  #define IDLE_TICK_MSEC 500 // time between LED movements 
  static uint32_t tm = millis();
  static int      led_index = 0;
  if (millis() - tm >= IDLE_TICK_MSEC)
  { tm = millis();
    // bump the LED
    led_index = (led_index+1) % 42;
    // render the pixels
    for (int i=0; i < 42; i++)
      pixels.setPixelColor(i, i == led_index ? pixels.Color(25, 25, 25) : pixels.Color(0, 0, 0));
    pixels.show();
  }
}
void loop() {

Below is the full code in case you'd need the entirety to look over:

/*
 * INITIAL AUTHOR: Dominick Civitano
 *
 * See: https://github.com/miguelbalboa/rfid/tree/master/examples/rfid_write_personal_data
 *
 * Uses MIFARE RFID card using RFID-RC522 reader
 * Uses MFRC522 - Library
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS      SDA(SS)      10            53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
*/
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 11; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 10; // Connects to module's TX

SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);

// Create the Player object
DFRobotDFPlayerMini player;
#endif

#include <SPI.h>
#include <MFRC522.h>
#define PIN 6
#define NUMPIXELS      42
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define RST_PIN         5           // Configurable, see typical pin layout above
#define SS_PIN          53          // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance

const int relay = 7; //relay control pin

//*****************************************************************************************//
void setup() {
  pinMode(relay,OUTPUT);
  Serial.begin(9600);                                           // Initialize serial communications with the PC
  softwareSerial.begin(9600);
  if (player.begin(softwareSerial)) {
    Serial.println("speaker on");

    // Set volume to maximum (0 to 30).
    player.volume(20);
    // Play the first MP3 file on the SD card
    
  }

  digitalWrite(relay, LOW);
  SPI.begin();  
  pixels.begin();
  pixels.show(); // Initialize all pixels to 'off'
// Init SPI bus
  mfrc522.PCD_Init();                                              // Init MFRC522 card
  Serial.println(F("Read personal data on a MIFARE PICC:"));    //shows in serial that it is ready to read
}

//*****************************************************************************************//
void disney(){

  pixels.setPixelColor(41, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(41, pixels.Color(0,0,0));
  pixels.setPixelColor(40, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(40, pixels.Color(0,0,0));
  pixels.setPixelColor(39, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(39, pixels.Color(0,0,0));
  pixels.setPixelColor(38, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(38, pixels.Color(0,0,0)); 
  pixels.setPixelColor(37, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(37, pixels.Color(0,0,0));
  pixels.setPixelColor(36, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(36, pixels.Color(0,0,0));
  pixels.setPixelColor(35, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(35, pixels.Color(0,0,0));
  pixels.setPixelColor(34, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(34, pixels.Color(0,0,0));
  pixels.setPixelColor(33, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(33, pixels.Color(0,0,0));
  pixels.setPixelColor(32, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(32, pixels.Color(0,0,0));
  pixels.setPixelColor(31, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(31, pixels.Color(0,0,0));
  pixels.setPixelColor(30, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(30, pixels.Color(0,0,0));
  pixels.setPixelColor(29, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(29, pixels.Color(0,0,0));
  pixels.setPixelColor(28, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(28, pixels.Color(0,0,0));
  pixels.setPixelColor(27, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(27, pixels.Color(0,0,0));
  pixels.setPixelColor(26, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(26, pixels.Color(0,0,0));
  pixels.setPixelColor(25, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(25, pixels.Color(0,0,0));
  pixels.setPixelColor(24, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(24, pixels.Color(0,0,0));  
  pixels.setPixelColor(23, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(23, pixels.Color(0,0,0));
  pixels.setPixelColor(22, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(22, pixels.Color(0,0,0));
  pixels.setPixelColor(21, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(21, pixels.Color(0,0,0));
  pixels.setPixelColor(20, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(20, pixels.Color(0,0,0));
  pixels.setPixelColor(19, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(19, pixels.Color(0,0,0));
  pixels.setPixelColor(18, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(18, pixels.Color(0,0,0));
  pixels.setPixelColor(17, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(17, pixels.Color(0,0,0));
  pixels.setPixelColor(16, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(16, pixels.Color(0,0,0));
  pixels.setPixelColor(15, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(15, pixels.Color(0,0,0));
  pixels.setPixelColor(14, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(14, pixels.Color(0,0,0));
  pixels.setPixelColor(13, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(13, pixels.Color(0,0,0));
  pixels.setPixelColor(12, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(12, pixels.Color(0,0,0));
  pixels.setPixelColor(11, pixels.Color(0,25,0));
  pixels.show();
  delay(50); 
  pixels.setPixelColor(11, pixels.Color(0,0,0));
  pixels.setPixelColor(10, pixels.Color(0,25,0));
  pixels.show();
  delay(50); 
  pixels.setPixelColor(10, pixels.Color(0,0,0));
  pixels.setPixelColor(9, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(9, pixels.Color(0,0,0));
  pixels.setPixelColor(8, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(8, pixels.Color(0,0,0));
  pixels.setPixelColor(7, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(7, pixels.Color(0,0,0));
  pixels.setPixelColor(6, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(6, pixels.Color(0,0,0));
  pixels.setPixelColor(5, pixels.Color(0,25,0));
  pixels.show();
  delay(50);  
  pixels.setPixelColor(5, pixels.Color(0,0,0));
  pixels.setPixelColor(4, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(4, pixels.Color(0,0,0));
  pixels.setPixelColor(3, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(3, pixels.Color(0,0,0));
  pixels.setPixelColor(2, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(2, pixels.Color(0,0,0));
  pixels.setPixelColor(1, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(1, pixels.Color(0,0,0));
  pixels.setPixelColor(0, pixels.Color(0,25,0));
  pixels.show();
  delay(50);
  pixels.setPixelColor(0, pixels.Color(0,0,0));
  pixels.show();
  delay(50);
}

void disneyaccess()
{
//  player.play(1); 

 pixels.setPixelColor(0, pixels.Color(0,25,0));
 pixels.setPixelColor(1, pixels.Color(0,25,0));
 pixels.setPixelColor(2, pixels.Color(0,25,0));
 pixels.setPixelColor(3, pixels.Color(0,25,0));
 pixels.setPixelColor(4, pixels.Color(0,25,0));
 pixels.setPixelColor(5, pixels.Color(0,25,0));
 pixels.setPixelColor(6, pixels.Color(0,25,0));
 pixels.setPixelColor(7, pixels.Color(0,25,0));
 pixels.setPixelColor(8, pixels.Color(0,25,0));
 pixels.setPixelColor(9, pixels.Color(0,25,0));
 pixels.setPixelColor(10, pixels.Color(0,25,0));
 pixels.setPixelColor(11, pixels.Color(0,25,0));
 pixels.setPixelColor(12, pixels.Color(0,25,0));
 pixels.setPixelColor(13, pixels.Color(0,25,0));
 pixels.setPixelColor(14, pixels.Color(0,25,0));
 pixels.setPixelColor(15, pixels.Color(0,25,0));
 pixels.setPixelColor(16, pixels.Color(0,25,0));
 pixels.setPixelColor(17, pixels.Color(0,25,0));
 pixels.setPixelColor(18, pixels.Color(0,25,0));
 pixels.setPixelColor(19, pixels.Color(0,25,0));
 pixels.setPixelColor(20, pixels.Color(0,25,0));
 pixels.setPixelColor(21, pixels.Color(0,25,0));
 pixels.setPixelColor(22, pixels.Color(0,25,0));
 pixels.setPixelColor(23, pixels.Color(0,25,0));
 pixels.setPixelColor(24, pixels.Color(0,25,0));
 pixels.setPixelColor(25, pixels.Color(0,25,0));
 pixels.setPixelColor(26, pixels.Color(0,25,0));
 pixels.setPixelColor(27, pixels.Color(0,25,0));
 pixels.setPixelColor(28, pixels.Color(0,25,0));
 pixels.setPixelColor(29, pixels.Color(0,25,0));
 pixels.setPixelColor(30, pixels.Color(0,25,0));
 pixels.setPixelColor(31, pixels.Color(0,25,0));
 pixels.setPixelColor(32, pixels.Color(0,25,0));
 pixels.setPixelColor(33, pixels.Color(0,25,0));
 pixels.setPixelColor(34, pixels.Color(0,25,0));
 pixels.setPixelColor(35, pixels.Color(0,25,0));
 pixels.setPixelColor(36, pixels.Color(0,25,0));
 pixels.setPixelColor(37, pixels.Color(0,25,0));
 pixels.setPixelColor(38, pixels.Color(0,25,0));
 pixels.setPixelColor(39, pixels.Color(0,25,0));
 pixels.setPixelColor(40, pixels.Color(0,25,0));
 pixels.setPixelColor(41, pixels.Color(0,25,0));
 pixels.show();
 
 if(digitalRead(relay) == HIGH)
    {
   digitalWrite(relay,LOW);
   Serial.println("Relay off"); 
   }
   else
   {
   digitalWrite(relay,HIGH);
   Serial.println("Relay on"); 
   }


}

void disneyoff()
{
pixels.setPixelColor(0, pixels.Color(0,0,0));
 pixels.setPixelColor(1, pixels.Color(0,0,0));
 pixels.setPixelColor(2, pixels.Color(0,0,0));
 pixels.setPixelColor(3, pixels.Color(0,0,0));
 pixels.setPixelColor(4, pixels.Color(0,0,0));
 pixels.setPixelColor(5, pixels.Color(0,0,0));
 pixels.setPixelColor(6, pixels.Color(0,0,0));
 pixels.setPixelColor(7, pixels.Color(0,0,0));
 pixels.setPixelColor(8, pixels.Color(0,0,0));
 pixels.setPixelColor(9, pixels.Color(0,0,0));
 pixels.setPixelColor(10, pixels.Color(0,0,0));
 pixels.setPixelColor(11, pixels.Color(0,0,0));
 pixels.setPixelColor(12, pixels.Color(0,0,0));
 pixels.setPixelColor(13, pixels.Color(0,0,0));
 pixels.setPixelColor(14, pixels.Color(0,0,0));
 pixels.setPixelColor(15, pixels.Color(0,0,0));
 pixels.setPixelColor(16, pixels.Color(0,0,0));
 pixels.setPixelColor(17, pixels.Color(0,0,0));
 pixels.setPixelColor(18, pixels.Color(0,0,0));
 pixels.setPixelColor(19, pixels.Color(0,0,0));
 pixels.setPixelColor(20, pixels.Color(0,0,0));
 pixels.setPixelColor(21, pixels.Color(0,0,0));
 pixels.setPixelColor(22, pixels.Color(0,0,0));
 pixels.setPixelColor(23, pixels.Color(0,0,0));
 pixels.setPixelColor(24, pixels.Color(0,0,0));
 pixels.setPixelColor(25, pixels.Color(0,0,0));
 pixels.setPixelColor(26, pixels.Color(0,0,0));
 pixels.setPixelColor(27, pixels.Color(0,0,0));
 pixels.setPixelColor(28, pixels.Color(0,0,0));
 pixels.setPixelColor(29, pixels.Color(0,0,0));
 pixels.setPixelColor(30, pixels.Color(0,0,0));
 pixels.setPixelColor(31, pixels.Color(0,0,0));
 pixels.setPixelColor(32, pixels.Color(0,0,0));
 pixels.setPixelColor(33, pixels.Color(0,0,0));
 pixels.setPixelColor(34, pixels.Color(0,0,0));
 pixels.setPixelColor(35, pixels.Color(0,0,0));
 pixels.setPixelColor(36, pixels.Color(0,0,0));
 pixels.setPixelColor(37, pixels.Color(0,0,0));
 pixels.setPixelColor(38, pixels.Color(0,0,0));
 pixels.setPixelColor(39, pixels.Color(0,0,0));
 pixels.setPixelColor(40, pixels.Color(0,0,0));
 pixels.setPixelColor(41, pixels.Color(0,0,0));
 pixels.show();
}

{//idle white LED circling
  #define IDLE_TICK_MSEC 500 // time between LED movements 
  static uint32_t tm = millis();
  static int      led_index = 0;
  if (millis() - tm >= IDLE_TICK_MSEC)
  { tm = millis();
    // bump the LED
    led_index = (led_index+1) % 42;
    // render the pixels
    for (int i=0; i < 42; i++)
      pixels.setPixelColor(i, i == led_index ? pixels.Color(25, 25, 25) : pixels.Color(0, 0, 0));
    pixels.show();
  }
}
void loop() {

  // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
  MFRC522::MIFARE_Key key;
  for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;

  //some variables we need
  byte block;
  byte len;
  MFRC522::StatusCode status;

  //-------------------------------------------

  // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  Serial.println(F("**Card Detected:**"));

  //-------------------------------------------
Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "04 4e b4 aa 15 75 80","04 4a a7 32 16 75 80","04 6a 78 52 16 75 80","04 21 60 52 60 74 80") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    disney();
    disney();
    disney();
    disneyaccess();
    player.play(1);
    delay(2000);
    disneyoff();
    Serial.println();
    
    delay(2500);

  }
 
 else   {
    Serial.println(" Access denied");
 }
  mfrc522.PICC_DumpDetailsToSerial(&(mfrc522.uid)); //dump some details about the card

  //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));      //uncomment this to see all blocks in hex

  //-------------------------------------------

  Serial.print(F("Name: "));

  byte buffer1[18];

  block = 4;
  len = 18;

  //------------------------------------------- GET FIRST NAME
  status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 4, &key, &(mfrc522.uid)); //line 834 of MFRC522.cpp file
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("Authentication failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

  status = mfrc522.MIFARE_Read(block, buffer1, &len);
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("Reading failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

  //PRINT FIRST NAME
  for (uint8_t i = 0; i < 16; i++)
  {
    if (buffer1[i] != 32)
    {
      Serial.write(buffer1[i]);
    }
  }
  Serial.print(" ");

  //---------------------------------------- GET LAST NAME

  byte buffer2[18];
  block = 1;

  status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 1, &key, &(mfrc522.uid)); //line 834
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("Authentication failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

  status = mfrc522.MIFARE_Read(block, buffer2, &len);
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("Reading failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

  //PRINT LAST NAME
  for (uint8_t i = 0; i < 16; i++) {
    Serial.write(buffer2[i] );
  }


  //----------------------------------------

  Serial.println(F("\n**End Reading**\n"));

  delay(1000); //change value if you want to read cards faster

  mfrc522.PICC_HaltA();
  mfrc522.PCD_StopCrypto1();
}
//*****************************************************************************************//

You can't have a part of the code outside functions.
most lines of code must be inside a function.

functions-definitions start with "void" then follows the name of the function followed by "()"
and after that there comes a opening brace "{"

void nameOfFunction()
{
}

As you are very new to programming. You should describe your wanted functionality in normal words.

To give your potential helpers a clear picture of what you want to do you should post
a picture or a youtube-link that shows what you want to do.

for more basic knowledge
Take a look into this tutorial:

Arduino Programming Course

It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.

best regards Stefan

Apologies for potentially not explaining it clear enough. In the video I'm linking it shows a little of the function starting at :26 seconds in. You'll see as they walk up the slow circling white. The version I am doing instead of the increasing speed of the white circling will be green.

https://youtu.be/XnfcY7nUhOI

Now as far as the function being where it is, it is in a entire void loop, so I would just need to give it a function name such as pixels.whiteloop() in the top under pixels.show and then right at the open function put {pixels.whiteloop //White LED Circling? If so, where would I fix the class Adafruit_neopixel member for whiteloop?

In the place where you have an opening brace with a comment - obviously should be a procedure name

{
pixels.setPixelColor(0, pixels.Color(0,0,0));
 pixels.setPixelColor(1, pixels.Color(0,0,0));
 .
.
.
 pixels.setPixelColor(40, pixels.Color(0,0,0));
 pixels.setPixelColor(41, pixels.Color(0,0,0));
 pixels.show();
}

@kyonkichi welcome to the forum. You are going to love learning to use for loops.

a&

No, you don't need to fix Adafruit, you just need to add the function type and name before the brace. The name shouldn't be related pixel class You can give it any desired name

You are still very poor on words.

So you mean you want to change the white color with the green color and that's it?

If you go on playing this very frustrating ping-pong-game of posting too short postings that just invoke new questions "do you mean this ? or do you mean that?"

You are in danger of loosing the willingness to help you.

There is a white light signal circling

You should describe in

detailed and normal words

what your light-animation should look like.

I have an RFID-reader laying around but I don't have a mind-reader laying around.

StefanL38;
I thought I was being clear enough. Allow me to try again.
What I am looking for is basically a copy of what Disney Magic Band readers at the parks do. I linked a video to show it, but it would be of course minus the finger print scanner.

It should be idle when powered on with a slow white, tracing, counter clockwise rotation of the LED's. This should constantly loop and be the default until a RFID card is presented. At this point I want the white tracing circle of LEDs to turn green, doing the same counter clockwise loop. Per each loop it should increase the speed of the loop. Loop should be 3-4 times with the increasing speed. After which all LED's should light solid green for 3ish seconds. At this point it is programmed to play the audio file with the solid flash of green. Once the solid flash turns off, it should go back to the idle loop of the white tracing counter clockwise. This should be the entirety of the function and idle sequencing.

If you watch the youtube linked in my other post, you will see the slow white counterclockwise led trace prior to them scanning the band, you'll see the white animation with increasing speed until it asks for finger print input where it will do the entire flash green and the sound output.

The only thing that is changed from that video in this code originally is that there is no finger print reader and instead of the white trace increasing speed they (Dominick Civitano) changed the color to green only as some of the readers use green instead of the white speed loop.

I drew out the sequence of events I am looking for as well if that may help to clarify things:
20221110-163156

if the href does not work, here is a direct link to the img

Ambitious and cool project.

Do you have a simple sketch for testing the RFID that gives you a great deal of confidence?

Can you make a timing diagram which shows the interactions you want between getting a RFID and stopping or switching or starting any LED effects? I see you just posted something, THX.

At a glance, the code for the LEDs will not play well with you trying to do anything else. If you want a responsive system you will need to change the approach or employ some ugly hacks.

It is advised to get both halves working separately, but writing them with the goal of combing them in mind..

Take a look at this thread:


state machine LED effects


and spend a few minutes at a few places on google

arduino state machine tutorial

If that looks within your grasp, it would probably be worth getting to some level of comfort before you write a buncha code.

a7

1 Like

OK, it looks like "white trace idle led slow" is the only thing that needs to be halted in process.

But what is the very first circle and arrow before it enters perpetual waiting WTILS?

a7

I started to play with the code a little bit based on some of the other suggestions per b707 and then started to think that that section of code may be in the wrong section. I moved it out of the void loop() section and moved it into the actual loop information. What I came up with is this. This also compiles with no errors stated. Hopefully this appears correct and someone may be able to confirm that I didn't do something silly instead.

void loop() {

  // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
  MFRC522::MIFARE_Key key;
  for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;

  //some variables we need
  byte block;
  byte len;
  MFRC522::StatusCode status;

  //-------------------------------------------

{ //idle white LED circling
  #define IDLE_TICK_MSEC 500 // time between LED movements 
  static uint32_t tm = millis();
  static int      led_index = 0;
  if (millis() - tm >= IDLE_TICK_MSEC)
  { tm = millis();
    // bump the LED
    led_index = (led_index+1) % 42;
    // render the pixels
    for (int i=0; i < 42; i++)
      pixels.setPixelColor(i, i == led_index ? pixels.Color(25, 25, 25) : pixels.Color(0, 0, 0));
    pixels.show();
  }
}

  // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  Serial.println(F("**Card Detected:**"));

  //-------------------------------------------

The original code works BEFORE trying to edit in this white LED loop. The original code can be gotten here. Only additional thing I've done to the code was to increase the pixel counts as original was only 23 led since he was using a 30 led string and I am using a 60 led string

Apologies for slow responses. My replies are hidden until mod approval due to being new.

As for the first circle showing on my diagram it should be just a constant white slow loop upon powerup until the RFID is presented. The very first image showing nothing is just a reference to what I am trying to portray. I believe that answers your question?

Also, if you would like a full code reference, I just uploaded it to Pastebin in case you would like to look it over in complete.

Yes, I think I see. There might be a long arrow from the last circle up to the 2nd cirlce (ilde).

So I took the pastebin code and stripped everything but the LED stuff.

I could not stand the literal and verbose code of the effects, so I rewrote them using "advanced" programming techniques. :wink:

I use a pushbutton to activate the "access granted" stuff. This could be supplanted by the RFID code that might just simply raise the same flag.

The "idle white LED circulating" code is non-blocking and is halted by the button press. Then the code goes deaf to the button for the duration of the access success.

I changed many of the time constants to make things go along a bit quicker. I have too little time left for any long delay()s. :expressionless:

BTW you say "I am using a 60 led string", but there's a strong idea of 42 in the code. At least if you do have a 60 LED strip, all you'll have to change is... wait for it... one number.

Play with it in the wokwi simulator here:


Disney RFIS thing

I recommend the wokwi, where the edit/compile/upload/cry cycle is less painful. It's free and you don't need an account. You should be able to get most of the LED effect stuff working the way you want w/o any need to worry about the RFID section. Or any hardware!

Speaking of which, how is your mechanical concept coming along? To me that might be where you will spend more time.


# include <Adafruit_NeoPixel.h>

# define PIN 6
# define NUMPIXELS      42

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
 
const int relay = 7; //relay control pin

void setup() {
  pinMode(relay,OUTPUT);
  Serial.begin(115200);

  pinMode(4, INPUT_PULLUP);

  digitalWrite(relay, LOW);

  pixels.begin();
  pixels.show(); // Initialize all pixels to 'off'

  delay(777);

  Serial.println(F("Not yet Read[ing] personal data on a MIFARE PICC:"));
}
 
void disney()
{
  for (char ledIndex = NUMPIXELS - 1; ledIndex--; ledIndex >= 0) {
    pixels.setPixelColor(ledIndex, pixels.Color(0,250,0));
    pixels.setPixelColor((ledIndex + 1) % NUMPIXELS, pixels.Color(0,0,0));
    pixels.show();
    delay(25);
  }
  pixels.setPixelColor(0, pixels.Color(0, 0, 0));
  pixels.show();
  delay(50);
}
 
void disneyaccess()
{
//  player.play(1); 

  for (unsigned char tt = 0; tt < NUMPIXELS; tt++)
    pixels.setPixelColor(tt, pixels.Color(0,250,0));

  pixels.show();
 
  if (digitalRead(relay) == HIGH) {
   digitalWrite(relay,LOW);
   Serial.println("Relay off"); 
  }
  else {
   digitalWrite(relay,HIGH);
   Serial.println("Relay on"); 
  }
}
 
void disneyoff()
{
  for (unsigned char tt = 0; tt < NUMPIXELS; tt++)
    pixels.setPixelColor(tt, pixels.Color(0,0,0));

  pixels.show();
}

bool access;    // set by pushbutton here, RFID later.

void loop() {

  access = checkButton();

 //idle white LED circling

  IWLC();

  if (access) {
    Serial.println("Authorized access");

    disney();
    disney();
    disney();
    disneyaccess();
//    player.play(1);
    delay(2000);
    disneyoff();
    Serial.println();

    delay(250);
  } 

  access = false;
}

// idle machine - moves LED around the ring clockwise. call it frequently.
void IWLC()
{
  #define IDLE_TICK_MSEC 47 // time between LED movements 
  static uint32_t tm = millis();
  static int      led_index = 0;
  if (millis() - tm >= IDLE_TICK_MSEC) {
    tm = millis();
    // bump the LED
    led_index = (led_index+1) % NUMPIXELS;
    // render the pixels
    for (int i=0; i < 42; i++)
      pixels.setPixelColor(i, i == led_index ? pixels.Color(200, 200, 200) : pixels.Color(0, 0, 0));
    pixels.show();
  }
}

/* hand made button debounce sets flag */
bool checkButton()
{
  static unsigned long lastButtonTime;
  static unsigned char lastButton = HIGH;
  unsigned long now = millis();
  bool returnCode = false;

  if (now - lastButtonTime > 50) {
    unsigned char thisButton = digitalRead(4);
    if (thisButton != lastButton) {

      if (!thisButton) {
        Serial.println("I see the button");
        returnCode = true;
      }

      lastButtonTime = now;
      lastButton = thisButton;
    }
  }

  return returnCode;
}

HTH

a7

Thank you for that, I'm sure yours would run much better due to actually knowing the programming.

Only question I have is since you are using pushbutton is that still doing to activate off the RFID? I only ask because I was programming the RFID tag from the magic bands from my sisters last visit in to be the activator.

Just was playing with that link you gave, the white should spin counter clockwise, would that be a changeable thing? As in change the code instead of starting 0 to 42 be reversed?

I chose 42 because that should be all I need out of the 60 and I would be cutting the string down.

Yes it is a changeable thing as you have the complete soucrecode available for changing it.

To be honest you should make a fundamental decision:
engaging a user to write the code for you for whatever value you agree about

or to put a little bit more effort into it by asking questions that are more specific and closer related to the code.

So please post your assumption where in the code it should be changed or simply save the WOKWI-project as a copy and test it there and then if it does not work post the new WOKWI-link with your code-version

best regards Stefan

Ok, I see.

All tricks are possible. Just using simple maths everyone might know, an effect can go backwards.

Everywhere the original referred to a pixel in a setPixelColor() call, say N, replace N with (NUMPIXELS - N + 1)...

Code says N = 0, (NUMPIXELS - N - 1) is NUMPIXESL - 1, the LED on the other end

Code says N = NUMPIXELS - 1, (NUMPIXELS - N - 1) is 0, the first LED.

numpixels 11
n reverse
0 10
1 9
2 8
3 7
4 6
5 5
6 4
7 3
8 2
9 1
10 0

As I said, everything but the LEDs (and relay) were totally stripped, so I could see and concentrate on the LED effects.

I asked about a separate RFID experiment or demo or test. Once you see what is going on, the logic value the pushbutton is now supplying can be swapped out for a flag coming from the RFID code.

There is no connection between the LEDs/relay/access display and the RFID looking for cards other than a single variable that says "got access, do the display".

Other than the intensity and timing, the LED stuff should be what you started us with.

Another way to make things go backwards is to flip the strip end-for-end in the physical world.

I prefer software. :expressionless:

HTH

a7

1 Like

Alto777,
Much appreciate your answer. I'll try to play with the reverse and re-applying the RFID stuff when I have some time off from work again. 13.5 hr days at the hospital gets to be taxing.

StefanL38,
Not sure what your issue is. I didn't ask Alto777 to write the new code he has, and as far as what I asked is just that, wondering if what I was originally going for with the RFID is possible still with the new code and if reversing them is a possibility. I didn't ask him to do it for me. However, if Alto777 would like compensation for his help, I'd be glad to since he's been the most help and honestly the one teaching me the most while trying to pick up something I've never done, he need only ask me. I stated in the very beginning, I only ever learned some cobolt and this is completely new to me. Sorry I am asking questions when I don't clearly know the possibility and just trying to get the information needed to continue. If this forum allowed private messages, which I've not seen the ability to, I'd probably engage Alto777 directly, even if it wasn't to have him code it for me just on the sheer basis he's been the only one to overly help a newbie. At least his answer on his recent post tells me its compatible with the RFID still and there is a way to reverse the direction. Both of which is all I asked.

Modifying the code that you used as a base (the code from Dominick Civitano) can be done in two ways:

  1. keeping yourself at the level of knowing almost nothing about C++ and asking for almost every single detail on what to do next.

  2. learning the basics about programming C++ and then beeing able to modify the easier things yourself. Of course still asking a lot of questions about the more advanced things
    or asking for explanations why some code acts the way it acts or how to modify some code to do what you want.

The fundamental difference betwen these two ways is:
not trying to analyse the code or

starting to analysing the code - at the beginning with unsecure guessings - but starting analysing.

If you look inside the code of alto777
what do you think which part of the code is doing running the single LED-pixel in white

There are some comments inside the code that will guide you
What is

your

assumption / your guessing which part of the code must be changed to rotate into the other direction.

best regards Stefan

I looked closer at the idle machine. The expression I offered earlier would work fine, but the code in IWLC() allows a simpler approach:

// bump the LED. clockwise
      led_index = led_index + 1; if (led_index >= NUMPIXELS) led_index = 0;

// or bump the LED. anti-clockwise
//    led_index = led_index - 1; if (led_index < 0) led_index = NUMPIXELS  - 1;

Just change which of the two lines is commented. If you look closely at those two line, you see one just makes a number cycle 0 to N - 1, the other goes from N - 1 to 0.

// idle machine - moves LED around the ring. call it frequently.
void IWLC()
{
  #define IDLE_TICK_MSEC 47 // time between LED movements 
  static uint32_t tm = millis();
  static int      led_index = 0;

  if (millis() - tm < IDLE_TICK_MSEC)  // time to move the LED along?
    return;                            // nope! nothing to do. yet.

// bump the LED. clockwise
  led_index = led_index + 1; if (led_index >= NUMPIXELS) led_index = 0;

// bump the LED. anti-clockwise
//  led_index = led_index - 1; if (led_index < 0) led_index = NUMPIXELS  - 1;

  for (int ii = 0; ii < NUMPIXELS; ii++) {
    pixels.setPixelColor(ii, ii == led_index ? pixels.Color(200, 200, 200) : pixels.Color(0, 0, 0));
    pixels.show();
  }
}

I only put all the LED stuff in the wokwi to see it. I cannot look at code and tell what effect an effect would have on me. Even the simulator is not the final test. I've been playing around with it some and it really pops on a ring of LEDs. I just got some 32 LED rings, so that's the magic NUMPIXELS number I put in.

And I did change dozens of lines of code into for loops in a few places.

I suggest @kyonkichi to simply read the code, pretend like you know what you are reading, line by line. The disney() function, for example. Then the somewhat more complicated idea of the idle machine which is IWLC().

As for the RFID, you have to think about the program as two separate things. In the current wokwi example, there's a section of code that handles seeing if the pushbutton is pressed. This exact section can be replaced by code that checks if a valid RFID has been swiped. It could as easily be a section that sees if the temperature is below 37 degrees celsius or checks that we are within 100 meters of the Eiffel Tower. Code is dumb - it don't know the difference, can't care. If a variable has been set that means "do something", it does it without regard to who said so.

So I would next, if you, get the RFID section alone working to simply say it had. Worked. Then that code can be placed into the LED code. The only logical connection between the two sections is the single variable that is the RFID section's indication to the LED section to do its thing.

a7

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.