I have an Adafruit NeoPixel ring that I am trying to make a function for. I want to be able to set the pixel, and have the OPTION of setting the color. If it's not set in the function, it will go to some default value (white for example). Something like this:
setLedDir(int led, int r, int g, int b);
where I can either put in the direction and color:
setLedDir(11, 255, 0, 0); // make LED #11 turn red.
... or just set the direction:
setLedDir(11); // make LED#11 turn white (the default value set by the function).
This is what I have now:
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel ring = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
void setup(){
ring.begin();
ring.show();
}
void loop(){
// The "on" led stopping in each quadrant for 0.5 seconds:
setLedDir(0);
delay(500);
setLedDir(3);
delay(500);
setLedDir(7);
delay(500);
setLedDir(11);
delay(500);
}
void setLedDir(int led, int r, int g, int b){
ring.clear();
ring.setPixelColor(led, r, g, b);
ring.show();
}
I get this error with this sketch:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Adafruit Flora"
sketch_mar24b.ino: In function 'void loop()':
sketch_mar24b:8: error: too few arguments to function 'void setLedDir(int, int, int, int)'
sketch_mar24b:14: error: at this point in file
sketch_mar24b:8: error: too few arguments to function 'void setLedDir(int, int, int, int)'
sketch_mar24b:16: error: at this point in file
sketch_mar24b:8: error: too few arguments to function 'void setLedDir(int, int, int, int)'
sketch_mar24b:18: error: at this point in file
sketch_mar24b:8: error: too few arguments to function 'void setLedDir(int, int, int, int)'
sketch_mar24b:20: error: at this point in file