Alright, so I'm new to the whole forum thing and the whole Arduino thing, but I'll keep it brief. If you want the full spill it's on Reddit: https://redd.it/5bxva6
So I'm trying to cycle colors on an RGB LED using a push button. I have no clue what I'm doing. I have turned a led on and off using buttons, but that's about it. I want it to cycle BLUE,GREEN,RED,YELLOW,CYAN,MAGENTA,WHITE when I press the button connected to pin 2. Here is what I've got:
// RGB LED lamp progress
//RGB LED pins
int ledDigitalOne[] = {8, 9, 10}; //the three digital pins of the digital LED
//9 = redPin, 10 = greenPin, 11 = bluePin
int sensorPin = A0; //Potentiometer to adjust brightness
const int colorbuttonPin = 2; //This is my button to change colors
const int patternbuttonPin = 3; //This is my button to cycle patterns
const boolean ON = LOW;
//Anode RGB LED (common pin is connected to +5 volts)
const boolean OFF = HIGH; //Define off as HIGH
//Predefined Colors
const boolean RED[] = {ON, OFF, OFF};
const boolean GREEN[] = {OFF, ON, OFF};
const boolean BLUE[] = {OFF, OFF, ON};
const boolean YELLOW[] = {ON, ON, OFF};
const boolean CYAN[] = {OFF, ON, ON};
const boolean MAGENTA[] = {ON, OFF, ON};
const boolean WHITE[] = {ON, ON, ON};
const boolean BLACK[] = {OFF, OFF, OFF};
//An Array that stores the predefined colors (allows us to later randomly display a color)
const boolean* COLORS[] = {RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA, WHITE, BLACK};
void setup () {
for(int i = 0; i < 3; i++){
pinMode(ledDigitalOne[i], OUTPUT); //Set the three LED pins as outputs
}
pinMode(colorbuttonPin, INPUT);
pinMode(patternbuttonPin, INPUT;
}
void loop() {
sensorValue = analogRead(sensorPin); // reads the potentiometers value
// I want to run this after I press the patternbutton on Pin 3
void randomColor(){
int rand = random(0, sizeof(COLORS) / 2); //get a random number within the range of colors
setColor(ledDigitalOne, COLORS[rand]); //Set the color of led one to a random color
delay(1000);
}
// Not quite sure how to make it conditional to when i toggle the button much less
// make it so I don't have to hold the button down. I want it to kinda be a toggle
// button, but not interfere with the color change button
// turning the RGB LED on will be in this area
delay (sensorValue); //This is for my Potentiometer brightness adjuster
//I think I have to turn the LED off here to make the potentiometer work as
// a brightness adjuster from what ive gathered
delay (sensorValue); //Potentiometer
}
Also a quick question. What does putton void before something do?
And I'm using a RGB LED from the ARDX Arduino kit
Any help would be appreciated thanks!