RGB Sketch gone south, help spot my error ?

I copied this sketch as best I could, the adafruit sketch (monk) copied alright but would past in one line straight across, so I did the best I could to copy it correctly.

Link to the sketch I'm trying to replicate:

https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds/arduino-sketch

  • note* I get an error msg,

'setColor was not declared in this scope.'

Here's the sketch I'm trying to compile:

//adafruit arduino lesson 3 rgb

int redPin=11; int greenPin =10; int bluePin=9;

void setup(){ pinMode(redPin,OUTPUT); pinMode (greenPin,OUTPUT); pinMode(bluePin,OUTPUT);

}

void loop () { setColor (255, 0, 0); delay(1000);

setColor(0,255,0); delay(1000 );

setColor(0,0,255); delay(1000) }

You don't have all the code. Try this:

/*
Adafruit Arduino - Lesson 3. RGB LED
*/

int redPin = 11;
int greenPin = 10;
int bluePin = 9;

//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE

void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);  
}

void loop()
{
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(0, 255, 0);  // green
  delay(1000);
  setColor(0, 0, 255);  // blue
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000);  
  setColor(80, 0, 80);  // purple
  delay(1000);
  setColor(0, 255, 255);  // aqua
  delay(1000);
}

void setColor(int red, int green, int blue)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
}