MorganS:
The compiler is right. colorWipe() wasn’t declared. It was commented out with //
The // comment style only comments one line. It doesn’t follow the { and } pairs to comment out a whole block. So by putting in that single //, you’ve effectively removed a { from your program. But the matching } is still there. You will have a LOT of errors.
Expand the error window at the bottom of your Arduino screen. Scroll up to the top to find the first error. Fix that one first. That will solve a lot of the lower errors.
The compiler is very smart. If you define a function but never use it, it won’t get put into the final executable code. So you don’t need to comment-out unneeded functions. Although it is a good idea to prune them away eventually, so you don’t have a lot of unreachable code that you have to read past.
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(30, PIN, NEO_GRB + NEO_KHZ800);
const int buttonPin = 1; // I chose pin 1 for the switch
int buttonState = 0; // I copied this as well as it's required for the switch to work
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
strip.begin();
strip.show();
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(0,255,0);
strip.show();
delay(wait);
}
}
//void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
} else {
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(0,255,0);
}
strip.show();
delay(wait);
}
}
//Theatre-style crawling lights.
//void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
//Theatre-style crawling lights with rainbow effect
//void theaterChaseRainbow(uint8_t wait) {
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
So I removed the // and now the error I’m getting is Arduino: 1.8.5 (Windows 10), Board: “Adafruit Trinket (ATtiny85 @ 16MHz)”
C:\Users\Iram\AppData\Local\Temp\arduino_modified_sketch_30678\strandtest.ino: In function ‘void loop()’:
strandtest:33: error: a function-definition is not allowed here before ‘{’ token
void colorWipe(uint32_t c, uint8_t wait) {
^
strandtest:115: error: expected ‘}’ at end of input
}
^
strandtest:115: error: expected ‘}’ at end of input
exit status 1
a function-definition is not allowed here before ‘{’ token
This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.