Hi
I'm trying to get my code to turn on and off at the push of a button but I'm having no luck could anyone help please, the code is to just cycle through 4 leds and 3 RGB's. i have pieced the code together from what i have found online. thanks in advance.
const int ledRed =11;
const int ledGreen =10;
const int ledBlue =9;
const int ledPinUV =6;
const int LedPin1 =5;
const int LedPin2 =3;
const int LedPin3 =2;
void setup() {
pinMode (ledRed, OUTPUT);
pinMode (ledGreen, OUTPUT);
pinMode (ledBlue, OUTPUT);
pinMode (ledPinUV, OUTPUT);
pinMode (LedPin1, OUTPUT);
}
void loop() {
analogWrite(ledPinUV, random(120)+135);
delay(random(250, 500));
CommandPWM_ON(ledBlue);
delay(random(250, 500));
CommandPWM_ON(ledGreen);
delay(random(250, 500));
CommandPWM_OFF(ledBlue);
CommandPWM_ON(ledRed);
delay(random(250, 500));
CommandPWM_OFF(ledGreen);
CommandPWM_ON(ledBlue);
delay(random(250, 500));
CommandPWM_ON(LedPin1);
delay(random(250, 500));
CommandPWM_ON(LedPin2);
delay(random(250, 500));
CommandPWM_ON(LedPin3);
delay(random(250, 500));
}
void CommandPWM_ON(int NumPin) {
for( int i = 0; i <= 255; i++ ) {
analogWrite(NumPin, i);
delay(5);
}
}
void CommandPWM_OFF(int NumPin) {
for( int i = 255; i >= 0; i-- ) {
analogWrite(NumPin, i);
delay(5);
}
}