Random Led Blinking With Brightness adjust

Hi everyone

I am new to tthis forum, im looking for a bit of guidence with a project of mine.

I have a trinket pro (3v) running a random led flashing code, i want to add two buttons to increase and

decrease the brightness without interfering with the random flashing code.

Can anyone give me a bit of a helping hand as im not really sure how to add it into my code.

This is what i have below

#define numberOfLights 12

byte pins[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
byte pinState[numberOfLights];
long int changeTime[numberOfLights];
int flashRate[numberOfLights];
long flashChange; // how often to change the flashing patterns

void setup() {
for(int i = 0; i< numberOfLights; i++) {
pinMode(pins*, OUTPUT);*
_ changeTime = millis() + random(50, 90);_
_ pinState = LOW;
* }
setFlashTime();
}
void loop() {
for(int i = 0; i < numberOfLights; i++) {
if(changeTime <= millis()) {_

pinState _= ~pinState;
digitalWrite(pins, pinState);_

changeTime _= millis() + flashRate;
}
}
if(flashChange <= millis()) setFlashTime();
}
void setFlashTime(){
for(int i=0; i<numberOfLights; i++){
flashRate = random(50, 500);
}
flashChange = millis() + 1500; // next time to change pattern*

}
Thanks alot for looking
Mike_

Handlink_Final_v1.ino (896 Bytes)

Due to limitations of the processor you'd only be practically able to change the brightness on pins 3, 5, 6, 9, 10, and 11. That's because only these pins have a hardware PWM available.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Thanks Tom I’ll take a look at it.

Here is my circuit

MikeDASH:
Here is my circuit

Sorry, Tom meant a circuit diagram.

While you are at it, go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon. In fact, the IDE has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window.

But don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. As you did not post it as "code", it is presently so badly garbled that we cannot discern whether it is properly indented, and it is always more difficult to read.

Apologies I don’t have a circuit design I just designed the pcb (as pictured) kind of fast and loose.

MikeDASH:
Apologies I don’t have a circuit design I just designed the pcb (as pictured) kind of fast and loose.

Okay, well now is the time to do a proper circuit diagram so we can all see the hardware you have connected to the controller.
Reverse engineering is good for the soul, it takes patience and you may find some design bugs as well.
Tom... :slight_smile: