I am trying to figure out what I did wrong in my sketch. In my void loop(), at the very bottom of the sketch, my if/else statement keeps compiling with the above error. Originally, it was an if/else if/else statement. I had the current else's an else if and the Update in my else. Someone had corrected me on it and i removed the code and made the proper changes and the error started. Now, just for the sake of my sanity I went ahead and put the ';' at the end of my else, which I know is wrong, just to see if it compiled, which it did. I ran the sketch and sure enough it broke the operation. I cannot figure out what it is looking for. Any help would be appreciated.
//ASHPD Barrel Version 4.0.2 (adding pulse) Created By Gixxerfool 01.11.2016
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Pattern types supported:
enum pattern {NONE, CHASE, PULSE};
#define orange 255,128,0
#define blue 0,0,255
char targetColor = '0,0,255';
// NeoPattern Class
class NeoPatterns : public Adafruit_NeoPixel
{
public:
// Member Variables:
pattern ActivePattern; // which pattern is running
unsigned long Interval; // milliseconds between updates
unsigned long lastUpdate; // last update of position
uint32_t Color1; // What color is used
uint16_t TotalSteps; // total number of steps in the pattern
uint16_t Index; // current step within the pattern
// Constructor
NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type)
:Adafruit_NeoPixel(pixels, pin, type)
{
}
// Update the pattern
void Update()
{
if ((millis() - lastUpdate) > Interval) // time to update
{
lastUpdate = millis();
switch (ActivePattern)
{
case CHASE:
ChaseUpdate();
break;
// case PULSE:
//PulseUpdate();
//break;
default:
break;
}
}
}
// Increment the Index and reset at the end
void Increment()
{
Index++;
if (Index >= TotalSteps)
{
Index = 0;
}
}
// Calculate 50% dimmed version of a color (used by ChaseUpdate)
uint32_t DimColor(uint32_t color)
{
// Shift R, G and B components one bit to the right
uint32_t dimColor = Color(Red(color) >> 1, Green(color) >> 1, Blue(color) >> 1);
return dimColor;
}
// Returns the Red component of a 32-bit color
uint8_t Red(uint32_t color)
{
return (color >> 16) & 0xFF;
}
// Returns the Green component of a 32-bit color
uint8_t Green(uint32_t color)
{
return (color >> 8) & 0xFF;
}
// Returns the Blue component of a 32-bit color
uint8_t Blue(uint32_t color)
{
return color & 0xFF;
}
// Initialize for a CHASE
void Chase(uint32_t color1, uint8_t interval)
{
ActivePattern = CHASE;
Interval = interval;
TotalSteps = (numPixels());
Color1 = color1;
Index = 0;
}
// Update the Chase Pattern
void ChaseUpdate()
{
for (int i = 0; i < numPixels() + 1; i++)
{
if (i == Index) // Scan Pixel
{
setPixelColor(i, Color1);
}
else // Fading tail
{
setPixelColor(i, DimColor(getPixelColor(i)));
}
}
show();
Increment();
}
//Initialize for a pulse
void Pulse(uint32_t color1, uint8_t interval)
{
ActivePattern = PULSE;
Interval = interval;
TotalSteps = 256;
Color1 = color1;
Index = 0;
}
//Update the Pulse
void PulseUpdate()
{
for (int h = 0; h < 256; h++)
{
for (int i = 0; i < 126; i++)
{
for (int j = 0; j > -1; j--)
{
if (h == Index)
{
setPixelColor(i, Color1);
}
else
{
setPixelColor(j, Color1);
}
}
show();
Increment();
}
}
}
};
// Define some NeoPatterns
NeoPatterns Ring3(16, 4, NEO_GRB + NEO_KHZ800);
NeoPatterns Ring2(12, 1, NEO_GRB + NEO_KHZ800);
NeoPatterns Ring1(7, 0, NEO_GRB + NEO_KHZ800);
// Initialize everything and prepare to start
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
pinMode(2, INPUT); //Sets pin 2 as an input
// Initialize all the pixels
Ring1.begin();
Ring2.begin();
Ring3.begin();
//Set all pixels to off
Ring1.show();
Ring2.show();
Ring3.show();
ring3Wipe(Ring3.Color(blue), 50); // Wipe ring 3 in blue once
ring2Wipe(Ring2.Color(blue), 50); // wipe ring 2 in Blue once
ring1FadeUpBlue(Ring1.Color(blue)); //Fade in ring1 once
//Start the idle pattern
//Name.PatternName(Name.Color(targetColor), Interval) Changing Interval will adjust the speed of the pattern
Ring1.Pulse(Ring1.Color(blue), 500);
Ring2.Chase(Ring2.Color(blue), 55);//keep the interval 15ms above ring3 for synchronicity
Ring3.Chase(Ring3.Color(blue), 40);//keep the interval 15ms below ring2 for synchronicity
}
void ring1FadeUpBlue(uint8_t wait)
{
for(int j = 0; j < 255; j++)
{
uint32_t color = Ring1.Color(0, 0, j ); // ramp up the blue only
for(uint16_t i=0; i < Ring1.numPixels(); i++)
{
Ring1.setPixelColor(i, color);
}
delay(7);
Ring1.show();
}
}
//wipes the ring2 once in blue
void ring2Wipe(uint32_t c, uint8_t wait)
{
for(uint16_t i=0; i < Ring2.numPixels(); i++) //This for loop runs reverse to ring3 loop
{
Ring2.setPixelColor(i, c);
Ring2.show();
delay(wait);
}
}
//wipes the ring3 once for the color blue
void ring3Wipe(uint32_t c, uint8_t wait)
{ //uint32_t and uint8_t are the colorWipe parameters c=color wait=#of ms between pixels. larger # slows the action
for(uint16_t i=0; i < Ring3.numPixels(); i++)
{
Ring3.setPixelColor(i, c);
Ring3.show();
delay(wait);
}
}
// Main loop
void loop()
{
// Update the rings.
Ring1.Update();
Ring2.Update();
Ring3.Update();
// check for button press:
if (digitalRead(2) == LOW) // Button is pressed
{
Ring3.Color1 = Ring3.Color(orange);//Change the target color to orange
Ring2.Color1 = Ring2.Color(orange);
Ring1.Color1 = Ring1.Color(orange);
}
else (digitalRead(2) == HIGH)//Kicks the color back to blue after the button is let go
{
Ring3.Color1 = Ring3.Color(blue);//Change the target color back to blue
Ring2.Color1 = Ring2.Color(blue);
Ring1.Color1 = Ring1.Color(blue);
}
}