exit status 1 'blink' was not declared in this scope

Hi Guys (and ladies)!

I'm a complete noob, so please be gentle!

I've been reading and reading, and cannot seem to figure out what I'm missing here.

I'm still in the "copy and paste" phase, so I'm sorry if I have a dumb question here.

I'd really appreciate it if one of you could peek at my code and see if you see any glaring errors.

Thanks oh so much! :slight_smile:

The error code is:

exit status 1
'blink' was not declared in this scope

/*Description:

  • This project is an Arduino Nano Controlling 60 ws2811 5V pixels. (Led Strip)
  • I need the Arduino to have 2 preset scenes which I can toggle with a momentary on Push button.
  • By default, when the arduino powers on, the lights will be a rainbow fade from one pixel to the next.
  • When I push the button, The lights will turn on Full White.
  • When I Push the button again, they will go back to rainbow.
  • Switch between Rainbow, and White.
    */

#include <Adafruit_NeoPixel.h>
#ifdef AVR
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Digital IO pin connected to the button. This will be driven with a
// pull-up resistor so the switch pulls the pin to ground momentarily.
// On a high -> low transition the button press logic will execute.
#define BUTTON_PIN 2

#define PIXEL_PIN 6 // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 60 // Number of NeoPixels

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ400);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

volatile byte mode = LOW; // Currently-active animation mode, 0-1
int i;
long firstPixelHue;

void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
strip.show(); // Initialize all pixels to 'off'
attachInterrupt digitalPinToInterrupt(BUTTON_PIN), blink, LOW);
Serial.begin(9600);
}

void loop() {

switch(mode) { // Start the new animation
case 0:
rainbow(); // Rainbow cycle along whole strip
break;
case 1:
colorWipe(strip.Color(255, 255, 255), 50); // white
i=0;
firstPixelHue = 0;
break;
}

}

This is the line that it doesn't seem to like:

attachInterrupt digitalPinToInterrupt(BUTTON_PIN), blink, LOW);

There is no blink function in the code

so just try removing it?

HoldenCaulfield:
so just try removing it?

The opposite. You need to add the function to the program

This line of code

 attachInterrupt digitalPinToInterrupt(BUTTON_PIN), blink, LOW);

Tells the Arduino to call the blink function when the BUTTON_PIN is LOW. You don't have a blink function. I also doubt that you need to use an interrupt to detect the button press

Hmmm. ok... I'm googling the heck out of this.. Thanks!

I can paint pixels, but can't seem to get it to switch back and forth. The whole "adding a button" part is a little above my pay grade at a total of about 6 hours messing with arduino..

I'm watching tutorial videos ad-nauseum, but haven't really found anything that directly addresses this. Info overload!

Uh! I'm a doofus!

I just noticed what I did.. I accidentally deleted the last section of the code... So sorry!

I think I have it now..

Thanks for making me re-trace my steps..

At least that's what it would say if you had the () right. Try

attachInterrupt (digitalPinToInterrupt(BUTTON_PIN), blink, LOW);

but you'll still need to write a blink ISR function. And there are a few other functions you need if you look at all the other errors. You don't have a rainbow() or a colorWipe() either.

Wherever you are copying and pasting from I think you've left rather too much behind.

Steve

yeah, all this: :-[ Thanks!

void loop() {

switch(mode) { // Start the new animation
case 0:
rainbow(); // Rainbow cycle along whole strip
break;
case 1:
colorWipe(strip.Color(255, 255, 255), 50); // white
i=0;
firstPixelHue = 0;
break;
}

}

void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow() {
if(firstPixelHue < 3*65536){

if(i<strip.numPixels()){
int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
i++;
}
if(i==strip.numPixels()){
i=0;
firstPixelHue += 256;
strip.show(); // Update strip with new contents
delay(10); // Pause for a moment
}
}

if(firstPixelHue == 3*65536) firstPixelHue = 0;

}

void blink() {
mode = !mode;
//Serial.println(mode);

}

if(firstPixelHue == 3*65536) Which processor are you running this on?

Please remember to use code tags when you post code.

Doesn't Phoebe know the answers to your questions? Your sister is, after all, the smartest kid ever!

:slight_smile:

PerryBebbington:
Doesn't Phoebe know the answers to your questions? Your sister is, after all, the smartest kid ever!

:slight_smile:

:slight_smile: