hey everyone ... i am new to programming so i hope someone can help me with my issue, and/or point me to the right direction.
i have some Led's attached to some shiftregisters ( 74ls138 ) what i am trying to do is to fade one led at a time in a random way. i wrote this code ( based on som posts i found on the net ) but it is not working and happing prblem with the "analogwrite" section.
any suggestion how i can do it ? any help is appreciated.
#define DATA1 8
#define DATA2 9
#define DATA3 10
int ran;
void setup() {
pinMode(DATA1, OUTPUT);
pinMode(DATA2, OUTPUT);
pinMode(DATA3, OUTPUT);
}
void loop() {
ran = random(8);
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(setPins(ran), fadeValue);
delay(30);
}
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(setPins(ran), fadeValue);
delay(30);
}
}
void setPins(int number){
boolean d1 = bitRead(number, 0);
boolean d2 = bitRead(number, 1);
boolean d3 = bitRead(number, 2);
digitalWrite(DATA1, d1);
digitalWrite(DATA2, d2);
digitalWrite(DATA3, d3);
}