1

My 10 year old received great gift from older brother (Crate Creations) and I am trying write the program and getting this error. It looks to me that I matched the required code word for word symbol for symbol but I just can't figure out what I did wrong:

void loop () {

  for (float x = 0; x < PI; x = x + 0.00001) {
    RGB[0] = power * abs(sin(x * (CommonMathVariable)));
    RGB[1] = power * abs(sin((x + PI/3) * (CommonMathVariable)));
    RGB[2] = power * abs(sin((x + (2 * PI) / 3) * (CommonMathVariable)));
    ambientLight = analogRead(ldrPin);
    if (ambientLight > 600) {

    analogWrite (redLed.RGB[0]);
    analogWrite (greenLed.RGB[1];
    analogWrite (blueLed.RGB[2];

  }

I get this error:

request for member 'RGB' in 'redLed' , which is of non-class type 'int'
3
  • 1
    Nick, Thanks so much...that got me past the error i have been stressing over... the booklet just looks like a period and not a comma....you rock..here is the rest of the code...after i corrected the comma i am getting an error for 'pulseSpeed not declared'
    – JayGarcia
    Commented Feb 5, 2017 at 12:02
  • for (int i = 0; i < 3; i++) { if (RGB[i] < 1) { delay (20 * pulseSpeed); } else if (RGB[i] < 5) { delay (10 * pulseSpeed); } else if (RGB[i] < 10) { delay (2 * pulseSpeed); } else if (RGB[i] < 100) { delay (1 * pulseSpeed); } else {} } delay (1); }
    – JayGarcia
    Commented Feb 5, 2017 at 12:05
  • I can't really make out that comment. This sounds like a different question. Can you make a new one please? On the face of it you haven't declared pulseSpeed, unless there is more code you haven't shown. A declaration looks like: type name, for example: int pulseSpeed;
    – Nick Gammon
    Commented Feb 6, 2017 at 5:14

1 Answer 1

3

Probably you didn't spot commas:

    analogWrite (redLed,   RGB[0]);
    analogWrite (greenLed, RGB[1]);
    analogWrite (blueLed,  RGB[2]);

The function analogWrite takes two arguments, separated by commas. You were missing some brackets as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.