Even when i press the reset button, the arduino doesn’t start.
#include <SPI.h>
#include "hsv2rgb.h"
const int ShiftPWM_latchPin=8;
const bool ShiftPWM_invertOutputs = 0; // if invertOutputs is 1, outputs will be active low. Usefull for common anode RGB led's.
#include <ShiftPWM.h> // include ShiftPWM.h after setting the pins!
int potPin = 0; // Potentiometer output connected to analog pin 0
int buttonPin = 2; // Butto output connected to digital pin 2
unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
unsigned char red, green, blue;
int numRegisters = 3;
int buttonState = 0;
int hue;
int val = 15;
int sat = 255;
int potValHue = 0; // Variable to store the input from the potentiometer
int delbright = 2; // delay of the brightnes in milliseconds
int delstrip = 300; // delay of the brightnes in milliseconds
void setup() {
pinMode(ShiftPWM_latchPin, OUTPUT);
pinMode(buttonPin, INPUT);
SPI.setBitOrder(LSBFIRST);
// SPI_CLOCK_DIV2 is only a tiny bit faster in sending out the last byte.
// SPI transfer and calculations overlap for the other bytes.
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.begin();
ShiftPWM.SetAmountOfRegisters(numRegisters);
ShiftPWM.Start(pwmFrequency,maxBrightness);
}
void loop()
{
ShiftPWM.SetAll(0);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
rgbledup();
}
else {
ShiftPWM.SetAll(0);
}
}
void rgbledup()
{
for(int ledstrip=0; ledstrip<6; ledstrip++){
hue = analogRead(potPin)/2.85; //Read the potentiometer, convert it to 0 - 360
for(int brightnes=0; brightnes<255; brightnes++){
hsv2rgb(hue, sat, val, &red, &green, &blue, brightnes); // convert hsv to rgb values
ShiftPWM.SetGroupOf3(ledstrip, blue, green, red);
delay(delbright);} //delay of Brightnes
delay(delstrip);} //delay between strips
delay(1000); //delay between on and off
for(int ledstrip=0; ledstrip<6; ledstrip++){
for(int brightnes=255; brightnes>0; brightnes--){
hsv2rgb(hue, sat, val, &red, &green, &blue, brightnes); // convert hsv to rgb values
ShiftPWM.SetGroupOf3(ledstrip, blue, green, red);
delay(delbright);} //delay of Brightnes
delay(delstrip);} //delay between strips
}
void rgbleddown()
{
for(int ledstrip=6; ledstrip>0; ledstrip--){
hue = analogRead(potPin)/2.85; //Read the potentiometer, convert it to 0 - 360
for(int brightnes=0; brightnes<255; brightnes++){
hsv2rgb(hue, sat, val, &red, &green, &blue, brightnes); // convert hsv to rgb values
ShiftPWM.SetGroupOf3(ledstrip, blue, green, red);
delay(delbright);} //delay of Brightnes
delay(delstrip);} //delay between strips
delay(1000); //delay between on and off
for(int ledstrip=6; ledstrip>0; ledstrip--){
for(int brightnes=255; brightnes>0; brightnes--){
hsv2rgb(hue, sat, val, &red, &green, &blue, brightnes); // convert hsv to rgb values
ShiftPWM.SetGroupOf3(ledstrip, blue, green, red);
delay(delbright);} //delay of Brightnes
delay(delstrip);} //delay between strips
}
This is the code i am using.
The Arduino is an Arduino Uno R3