Pages: [1]   Go Down
Author Topic: Compiler Error - 'Color' was not declared in this scope  (Read 1284 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm getting the error 'Color' was not declared in this scope on the code below with c = Color(255,0,0); being highlighted. I'm trying to get the LPD8806 LED strips to run a color pattern from the center and I'm missing something that's preventing the code to compile.

Thanks,
Phil

Code:
   #include "LPD8806.h"
    #include "SPI.h"

    int dataPin = 2;  
    int clockPin = 3;
    const int numPixels = 32;

    LPD8806 strip = LPD8806(32, dataPin, clockPin);

    void loop() {
          int i;
          uint32_t c;

          // Set all pixels to red
          c = Color(255,0,0);
          for (i=0; i < strip.numPixels(); i++) {
              strip.setPixelColor(i, c);
          }
          strip.show();
          delay(100);

    
          // Wipe from middle:
          c = Color(255, 255, 255); // white
          for (i=strip.numPixels() / 2 - 1; i >= 0; i--) { // half of strip, count down to 0
            strip.setPixelColor(i, c); // left pixel
            strip.setPixelColor(strip.numPixels() - 1 - i, c); // right pixel
            strip.show();
            delay(100);
          }
    }
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Uh-oh... where is the setup? Even if you don't use the setup, you must do this:
Code:
void setup(){
}
Oh right, on the line of c = Color(255,0,0); you need to do this instead:
Code:
c = strip.Color(255,0,0);
P.S. I replied 6 minutes after you posted!
« Last Edit: May 18, 2012, 07:10:03 pm by dkl65 » Logged


California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm getting the error 'Color' was not declared in this scope on the code below with c = Color(255,0,0); being highlighted. I'm trying to get the LPD8806 LED strips to run a color pattern from the center and I'm missing something that's preventing the code to compile.
Looks like Color is a member function of the object created. Just as you did with all the other member functions, you need to tell the compiler which object to call that function for.
« Last Edit: May 18, 2012, 05:10:48 pm by Arrch » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
P.S. I replied 6 minutes after you posted!

And it works...thanks for the quick help!

Phil
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3643
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And the setup must be before the loop.
Most assuredly, not the case. Try it with the most trivial example.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Most assuredly, not the case. Try it with the most trivial example.
Huh?
Logged


Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 246
Code Monkey
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Most assuredly, not the case. Try it with the most trivial example.
Huh?

The order of the standard function definitions does not matter:

Code:
void loop() {
   // Do nothing
}

void setup() {
  // WAT?
}

This code works fine.
Logged

I yield() for co-routines.

Pages: [1]   Go Up
Jump to: