compiling for board

help I have no idea how to fix this
sorry for the edits I'm still learning the site
theses are the errors i get
pixelstick:44: error: expected constructor, destructor, or type conversion before '(' token
pixelstick:45: error: expected constructor, destructor, or type conversion before '.' token
pixelstick:46: error: expected unqualified-id before 'if'
pixelstick:49: error: expected constructor, destructor, or type conversion before '(' token
pixelstick:50: error: expected constructor, destructor, or type conversion before ';' token
pixelstick:52: error: expected declaration before '}' token

#include <Adafruit_NeoPixel.h>

// Neopixel data pin
#define PIN 6
// SD card CS pin
#define SDPin 4

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// * SD card attached as follows:
// ** MOSI - pin 11
// ** MISO - pin 12
// ** CLK - pin 13
// ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

#include <SPI.h>
#include <SD.h>

// Neopixel data pin
#define PIN 6
// SD card CS pin
#define SDPin 4

int buttonPin = 2;
bool playAnimation = true;
int buttonState = 0;
int file_position = 0;
int m_NumberOfFiles = 0;
bool runAnimation = true;
String m_FileNames[10];
File root;
File dataFile;
String m_CurrentFilename = "";

int number_of_leds = 60;

delay(500);
Serial.print("Sending file");
if ( file_position >= m_NumberOfFiles) {
file_position = 0;
}
SendFile(m_FileNames[file_position]);
ClearStrip();

}

void setupSDcard() {
pinMode(SDPin, OUTPUT);

while (!SD.begin(SDPin)) {
Serial.println("SD init failed!");
delay(500);
}
Serial.println("SD init done");
delay(1000);
root = SD.open("/");
Serial.println("Scanning files");
delay(500);
GetFileNamesFromSD(root);
}

// This function lists files inside the SD card
void GetFileNamesFromSD(File dir) {
int fileCount = 0;
String CurrentFilename = "";
while(1) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
m_NumberOfFiles = fileCount;
Serial.println("total files");
Serial.println(fileCount);
entry.close();
break;
}
else {
CurrentFilename = entry.name();
if (CurrentFilename.endsWith(".TXT")) { //only txt files
if(CurrentFilename.startsWith("_")){ // mac sidecar files start with _ and should not be included, may be on card if written from Mac
}else{
m_FileNames[fileCount] = entry.name();
fileCount++;
}
}
}
entry.close();
}
}

// This function blinks the top led twice and starts the animation
void SendFile(String Filename) {
char temp[14];
runAnimation = true;
Filename.toCharArray(temp,14);
Serial.println(Filename);
dataFile = SD.open(temp);
// if the file is available send it to the LED's
if (dataFile) {
int i = 0;
int red, green, blue;
strip.setPixelColor(1,255,255,255);
strip.show();
delay(500);
strip.setPixelColor(1,0,0,0);
strip.show();
delay(500);
strip.setPixelColor(1,255,255,255);
strip.show();
delay(500);
strip.setPixelColor(1,0,0,0);
strip.show();
delay(2000);
while(dataFile.available() && runAnimation){

if (digitalRead(buttonPin) == HIGH) {
runAnimation = false;
break;
delay(100);
}
if (i == (number_of_leds)) {
i=0;
strip.show();
delay(120);
}
red = dataFile.parseInt();
green = dataFile.parseInt();
blue = dataFile.parseInt();
strip.setPixelColor(i, red, green, blue);
i++;
}
Serial.print("closing file");
dataFile.close();
} else {
Serial.print(" Error reading ");
setupSDcard();
return;
}
}

// Turn all LED off on the pixelstick
void ClearStrip() {
int x;
for(x=0;x<number_of_leds;x++) {
strip.setPixelColor(x, 0);
}
strip.show();
}
void setup() {
Serial.begin(115200);
pinMode(buttonPin, INPUT);
pinMode(13, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(5,HIGH);
strip.begin();
strip.show();
setupSDcard();
delay(100);
}

void loop() {
if (digitalRead(buttonPin) == HIGH) {
digitalWrite(13,HIGH);
file_position++;
Serial.println(file_position);
delay(100);
digitalWrite(13,LOW);
}
delay(500);
Serial.print("Sending file");
if ( file_position >= m_NumberOfFiles) {
file_position = 0;
}
SendFile(m_FileNames[file_position]);
ClearStrip();

}
<>

Maybe:

 static const uint8_t PROGMEM _sineTable[] = { _S3_, _S3_, _S3_, _S3_ }; // 256

... but depends on what is S3. There is double to byte conversion error, it means _sineTable and S3 are also probably different types.

Great for Snippets R US!

Where's your code buckrussel?

Upgrade to 1.8.7.


ARDUINO 1.8.7 2018.09.11

(bugfix service release)
...

  • AVR: Treat "narrowing conversion" as warning, not error. This will make some libraries to compile again. Thanks @PaulStoffregen

septillion:
Great for Snippets R US!

The best answer so far. :slight_smile:

oqibidipo:
Upgrade to 1.8.7.

... or update the Adafruit Neopixel library.
It no longer uses this GCC preprocessor trick:

// This bizarre construct isn't Arduino code in the conventional sense.
// It exploits features of GCC's preprocessor to generate a PROGMEM
// table (in flash memory) holding an 8-bit unsigned sine wave (0-255).
static const int _SBASE_ = __COUNTER__ + 1; // Index of 1st __COUNTER__ below
#define _S1_ (sin((__COUNTER__ - _SBASE_) / 128.0 * M_PI) + 1.0) * 127.5 + 0.5,
#define _S2_ _S1_ _S1_ _S1_ _S1_ _S1_ _S1_ _S1_ _S1_ // Expands to 8 items
#define _S3_ _S2_ _S2_ _S2_ _S2_ _S2_ _S2_ _S2_ _S2_ // Expands to 64 items
static const uint8_t PROGMEM _sineTable[] = { _S3_ _S3_ _S3_ _S3_ }; // 256

but has this more regular initialization:

/* A PROGMEM (flash mem) table containing 8-bit unsigned sine wave (0-255).
   Copy & paste this snippet into a Python REPL to regenerate:
import math
for x in range(256):
    print("{:3},".format(int((math.sin(x/128.0*math.pi)+1.0)*127.5+0.5))),
    if x&15 == 15: print
*/
static const uint8_t PROGMEM _sineTable[256] = {
  128,131,134,137,140,143,146,149,152,155,158,162,165,167,170,173,
  176,179,182,185,188,190,193,196,198,201,203,206,208,211,213,215,
...
#include <Adafruit_NeoPixel.h>

// Neopixel data pin
#define PIN 6
// SD card CS pin
#define SDPin 4


// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// * SD card attached as follows:
// ** MOSI - pin 11
// ** MISO - pin 12
// ** CLK - pin 13
// ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

#include <SPI.h>
#include <SD.h>

// Neopixel data pin
#define PIN 6
// SD card CS pin
#define SDPin 4

int buttonPin = 2;
bool playAnimation = true;
int buttonState = 0;
int file_position = 0;
int m_NumberOfFiles = 0;
bool runAnimation = true;
String m_FileNames[10];
File root;
File dataFile;
String m_CurrentFilename = "";

int number_of_leds = 3;

void setup() {
 Serial.begin(115200);
 pinMode(buttonPin, INPUT);
 pinMode(13, OUTPUT);
 pinMode(5, OUTPUT);
 digitalWrite(5,HIGH);
 strip.begin();
 strip.show();
 setupSDcard();
 delay(100);
}

void loop() {
  if (digitalRead(buttonPin) == HIGH) {
     digitalWrite(13,HIGH);
     file_position++;
     Serial.println(file_position);
     delay(100);
     digitalWrite(13,LOW);
   }
  delay(500);
   Serial.print("Sending file");
   if ( file_position >= m_NumberOfFiles) {
    file_position = 0;
   }
   SendFile(m_FileNames[file_position]);
   ClearStrip();

}


void setupSDcard() {
 pinMode(SDPin, OUTPUT);

 while (!SD.begin(SDPin)) {
   Serial.println("SD init failed!");
   delay(500);
 }
 Serial.println("SD init done");
 delay(1000);
 root = SD.open("/");
 Serial.println("Scanning files");
 delay(500);
 GetFileNamesFromSD(root);
}

// This function lists files inside the SD card
void GetFileNamesFromSD(File dir) {
 int fileCount = 0;
 String CurrentFilename = "";
 while(1) {
   File entry =  dir.openNextFile();
   if (! entry) {
     // no more files
     m_NumberOfFiles = fileCount;
     Serial.println("total files");
     Serial.println(fileCount);
   entry.close();
     break;
   }
   else {
       CurrentFilename = entry.name();
       if (CurrentFilename.endsWith(".TXT")) { //only txt files
         if(CurrentFilename.startsWith("_")){      // mac sidecar files start with _ and should not be included, may be on card if written from Mac
         }else{
           m_FileNames[fileCount] = entry.name();
           fileCount++;
         }
       }
   }
   entry.close();
 }
}

// This function blinks the top led twice and starts the animation
void SendFile(String Filename) {
 char temp[14];
 runAnimation = true;
 Filename.toCharArray(temp,14);
 Serial.println(Filename);
 dataFile = SD.open(temp);
 // if the file is available send it to the LED's
 if (dataFile) {
   int i = 0;
   int red, green, blue;
   strip.setPixelColor(1,255,255,255);
   strip.show();
   delay(500);
   strip.setPixelColor(1,0,0,0);
   strip.show();
   delay(500);
   strip.setPixelColor(1,255,255,255);
   strip.show();
   delay(500);
   strip.setPixelColor(1,0,0,0);
   strip.show();
   delay(2000);
   while(dataFile.available() && runAnimation){

     if (digitalRead(buttonPin) == HIGH) {
       runAnimation = false;
       break;
       delay(100);
     }
     if (i == (number_of_leds)) {
       i=0;
       strip.show();
       delay(120);
       }
     red = dataFile.parseInt();
     green = dataFile.parseInt();
     blue = dataFile.parseInt();
     strip.setPixelColor(i, red, green, blue);
     i++;
   }
   Serial.print("closing file");
   dataFile.close();
 } else {
   Serial.print("  Error reading ");
   setupSDcard();
   return;
   }
 }

// Turn all LED off on the pixelstick
void ClearStrip() {
 int x;
 for(x=0;x<number_of_leds;x++) {
   strip.setPixelColor(x, 0);
 }
 strip.show();
}

the errors i get from this code is

sketch_sep28a:1: error: missing terminating " character
sketch_sep28a:5: error: missing terminating " character
sketch_sep28a:5: error: variable or field 'GetFileNamesFromSD' declared void
sketch_sep28a:5: error: 'File' was not declared in this scope
sketch_sep28a:1: error: expected unqualified-id before string constant
In file included from sketch_sep28a.ino:7:
C:\Users\username\Documents\Arduino\libraries\Adafruit_NeoPixel/Adafruit_NeoPixel.h:121: error: 'neoPixelType' has not been declared
C:\Users\jamie user name\Documents\Arduino\libraries\Adafruit_NeoPixel/Adafruit_NeoPixel.h:135: error: 'neoPixelType' has not been declared
sketch_sep28a.ino: In function 'void setup()':
sketch_sep28a:56: error: 'strip' was not declared in this scope
sketch_sep28a.ino: In function 'void setupSDcard()':
sketch_sep28a:93: error: 'GetFileNamesFromSD' was not declared in this scope
sketch_sep28a.ino: In function 'void SendFile(String)':
sketch_sep28a:135: error: 'strip' was not declared in this scope
sketch_sep28a.ino: In function 'void ClearStrip()':
sketch_sep28a:178: error: 'strip' was not declared in this scope
sketch_sep28a:180: error: 'strip' was not declared in this scope

i know there all in the right pin i cant figure out whats going on with theses please help thank you.

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

#include <Adafruit_NeoPixel.h>

// Neopixel data pin
#define PIN 6
// SD card CS pin
#define SDPin 4


// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// * SD card attached as follows:
// ** MOSI - pin 11
// ** MISO - pin 12
// ** CLK - pin 13
// ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

#include <SPI.h>
#include <SD.h>

// Neopixel data pin
#define PIN 6
// SD card CS pin
#define SDPin 4

int buttonPin = 2;
bool playAnimation = true;
int buttonState = 0;
int file_position = 0;
int m_NumberOfFiles = 0;
bool runAnimation = true;
String m_FileNames[10];
File root;
File dataFile;
String m_CurrentFilename = "";

int number_of_leds = 3;

void setup() {
 Serial.begin(115200);
 pinMode(buttonPin, INPUT);
 pinMode(13, OUTPUT);
 pinMode(5, OUTPUT);
 digitalWrite(5,HIGH);
 strip.begin();
 strip.show();
 setupSDcard();
 delay(100);
}

void loop() {
  if (digitalRead(buttonPin) == HIGH) {
     digitalWrite(13,HIGH);
     file_position++;
     Serial.println(file_position);
     delay(100);
     digitalWrite(13,LOW);
   }
  delay(500);
   Serial.print("Sending file");
   if ( file_position >= m_NumberOfFiles) {
    file_position = 0;
   }
   SendFile(m_FileNames[file_position]);
   ClearStrip();

}


void setupSDcard() {
 pinMode(SDPin, OUTPUT);

 while (!SD.begin(SDPin)) {
   Serial.println("SD init failed!");
   delay(500);
 }
 Serial.println("SD init done");
 delay(1000);
 root = SD.open("/");
 Serial.println("Scanning files");
 delay(500);
 GetFileNamesFromSD(root);
}

// This function lists files inside the SD card
void GetFileNamesFromSD(File dir) {
 int fileCount = 0;
 String CurrentFilename = "";
 while(1) {
   File entry =  dir.openNextFile();
   if (! entry) {
     // no more files
     m_NumberOfFiles = fileCount;
     Serial.println("total files");
     Serial.println(fileCount);
   entry.close();
     break;
   }
   else {
       CurrentFilename = entry.name();
       if (CurrentFilename.endsWith(".TXT")) { //only txt files
         if(CurrentFilename.startsWith("_")){      // mac sidecar files start with _ and should not be included, may be on card if written from Mac
         }else{
           m_FileNames[fileCount] = entry.name();
           fileCount++;
         }
       }
   }
   entry.close();
 }
}

// This function blinks the top led twice and starts the animation
void SendFile(String Filename) {
 char temp[14];
 runAnimation = true;
 Filename.toCharArray(temp,14);
 Serial.println(Filename);
 dataFile = SD.open(temp);
 // if the file is available send it to the LED's
 if (dataFile) {
   int i = 0;
   int red, green, blue;
   strip.setPixelColor(1,255,255,255);
   strip.show();
   delay(500);
   strip.setPixelColor(1,0,0,0);
   strip.show();
   delay(500);
   strip.setPixelColor(1,255,255,255);
   strip.show();
   delay(500);
   strip.setPixelColor(1,0,0,0);
   strip.show();
   delay(2000);
   while(dataFile.available() && runAnimation){

     if (digitalRead(buttonPin) == HIGH) {
       runAnimation = false;
       break;
       delay(100);
     }
     if (i == (number_of_leds)) {
       i=0;
       strip.show();
       delay(120);
       }
     red = dataFile.parseInt();
     green = dataFile.parseInt();
     blue = dataFile.parseInt();
     strip.setPixelColor(i, red, green, blue);
     i++;
   }
   Serial.print("closing file");
   dataFile.close();
 } else {
   Serial.print("  Error reading ");
   setupSDcard();
   return;
   }
 }

// Turn all LED off on the pixelstick
void ClearStrip() {
 int x;
 for(x=0;x<number_of_leds;x++) {
   strip.setPixelColor(x, 0);
 }
 strip.show();
}

the errors i get from this code is

sketch_sep28a:1: error: missing terminating " character
sketch_sep28a:5: error: missing terminating " character
sketch_sep28a:5: error: variable or field 'GetFileNamesFromSD' declared void
sketch_sep28a:5: error: 'File' was not declared in this scope
sketch_sep28a:1: error: expected unqualified-id before string constant
In file included from sketch_sep28a.ino:7:
C:\Users\username\Documents\Arduino\libraries\Adafruit_NeoPixel/Adafruit_NeoPixel.h:121: error: 'neoPixelType' has not been declared
C:\Users\user name\Documents\Arduino\libraries\Adafruit_NeoPixel/Adafruit_NeoPixel.h:135: error: 'neoPixelType' has not been declared
sketch_sep28a.ino: In function 'void setup()':
sketch_sep28a:56: error: 'strip' was not declared in this scope
sketch_sep28a.ino: In function 'void setupSDcard()':
sketch_sep28a:93: error: 'GetFileNamesFromSD' was not declared in this scope
sketch_sep28a.ino: In function 'void SendFile(String)':
sketch_sep28a:135: error: 'strip' was not declared in this scope
sketch_sep28a.ino: In function 'void ClearStrip()':
sketch_sep28a:178: error: 'strip' was not declared in this scope
sketch_sep28a:180: error: 'strip' was not declared in this scope

i know there all in the right pin i cant figure out whats going on with theses please help thank you.

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

DON'T CROSS POST!!!!!!!!!!!!!!!!!!!!
http://forum.arduino.cc/index.php?topic=570678
I HAVE REPORTED THIS THREAD TO THE MODERATORS

Duplicate posts waste the time of the people helping you. I might spend 15 minutes writing a detailed answer on this thread, without knowing that someone already did the same in the other thread. This behavior is very disrespectful to the people you're asking for assistance. Just because we give our time freely doesn't mean it has no value.

In the future, take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, which you would already know if you had bothered reading the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Let's start with a very basic problem.
You have not created a NeoPixel object named strip.

thank you for helping. how do i go about making a named object?
im still noob for about 3 weeks now lol

First, get some sleep. Then, go back and fix your post by adding code tags ("</>" button).

When I compile your code, I get errors about 'strip' not being declared.

buckrussel:
thank you for helping. how do i go about making a named object?
im still noob for about 3 weeks now lol

Look at the examples that came with the library.

@buckrussel, do not cross-post again. Threads merged.

thats one of the errors i kept running into the leds are connected to the right pin and the other code i tried for strand test went over with no problems and worked great

buckrussel:
thats one of the errors i kept running into the leds are connected to the right pin and the other code i tried for strand test went over with no problems and worked great

reply #11
reply #14

And as indicated in reply #15, compare the first part of your code against the examples. You're missing the declaration of 'strip'.