Using digital pins to fade LED

so I'm working on a project and need to control individual LEDs on pins 1-12 (digital pins). I need the LEDs to fade/ pulse in and out. i need to be able to control each individual LED independently of the others with all of them running at the same time.

I have NO idea how to code this, I'm new to programming arduinos.

If someone could help me out that would be great!!

if you can give me some code that would work that would be incredible!!

for reference, I'm using an arduino micro

Thank you so much!!!

first question..

how do you intend on controlling the leds?

second question.. what is it exactly are you trying to accomplish?

the more specific info you give, the better we can help you with.. so go into detail.. exactly how many leds.. are they single color, bi-color, rgb??? starting to see why specifics are a must?

and start looking into 74HC595 or TLC5940 - (or other) if you're going to control a bunch of leds... saves pins ;)

good video for starters: https://www.youtube.com/watch?v=FehBLNHMlfo

insignia: first question..

how do you intend on controlling the leds?

second question.. what is it exactly are you trying to accomplish?

the more specific info you give, the better we can help you with.. so go into detail.. exactly how many leds.. are they single color, bi-color, rgb??? starting to see why specifics are a must?

I need the leds to run by themselves without any other input once the program is uploaded to the arduino but i need to be able to control the brightness and duration of the fade/pulse for each individual led independently of the others

i will be controlling exactly 12 leds. on the digital pins, 2-13 (i accidentally said 1-12 before)

they are single color leds

k, each chip will control 8 single color leds..

potentiometer and a button... press button to select led and then use the potentiometer to deal with brightness/fade manually

as far as auto.. that's more in the coding... and i end here cause i'm still learning myself - (unless it's something simple, but you haven't given enough info, so i'll assume it's not gonna be a simple project).. but atleast i gave you some info to look into

insignia:
k, each chip will control 8 single color leds…

potentiometer and a button… press button to select led and then use the potentiometer to deal with brightness/fade manually

as far as auto… that’s more in the coding… and i end here cause i’m still learning myself - (unless it’s something simple, but you haven’t given enough info, so i’ll assume it’s not gonna be a simple project)… but atleast i gave you some info to look into

doesn’t that defeat the whole point though? because then i would have to manually adjust it physically. The while point is that this will be in a completely enclosed housing in which i can’t access it later to fix things. unless I’m reading it wrong I’m not sure where you’re going with the button and the potentiometer

You never said how you wanted to control them.

aarg: You never said how you wanted to control them.

agreed...

also, make sure ALL your leds are either common cathode OR common anode,, do not mix em, it will only mess you up..

Pin 1 is not a good choice if you expect to use the serial interface.

hi

i do have a project, that states everything you need. but i do not know how it will run on the micro. you can create Arrays which have the Sequence for the leds. you can controll Fadetime, Scenetime, and output value.

this only works on PWM channels

brandontod97: doesn't that defeat the whole point though? because then i would have to manually adjust it physically. The while point is that this will be in a completely enclosed housing in which i can't access it later to fix things. unless I'm reading it wrong I'm not sure where you're going with the button and the potentiometer

i gave you basics.. for manually, and i did say "auto" would be in coding.... but when building something.. you should always give yourself a backdoor option incase ever needed.. AGAIN, you never said what it was yer building or how you intended on controlling the leds.. as AARG reminded you..

so.. you have to be more specific.. so how can anyone help you without specifics? what will it be used for (purpose)? the more detailed you are the better help you will get. we can't help you if we don't know what it is yer trying to accomplish.. controlling leds is more in detail depending on the project.

ex:

you can make an led game on 100 leds and you can build a 100 led audio visual organ.. each are controlled differently.. see what i mean? what is it that yer trying to make? telling us you want to control 12 single color leds seperately isn't enough info for us to go on.. just saying

aarg:
You never said how you wanted to control them.

i want to be able to program them to fade a particular way like this:

/*
Fading

This example shows how to fade an LED using the analogWrite() function.

The circuit:
* LED attached from digital pin 9 to ground.

Created 1 Nov 2008
By David A. Mellis
modified 30 Aug 2011
By Tom Igoe

http://www.arduino.cc/en/Tutorial/Fading

This example code is in the public domain.

*/


int ledPin = 9;    // LED connected to digital pin 9

void setup() {
 // nothing happens in setup
}

void loop() {
 // fade in from min to max in increments of 5 points:
 for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
   // sets the value (range from 0 to 255):
   analogWrite(ledPin, fadeValue);
   // wait for 30 milliseconds to see the dimming effect
   delay(30);
 }

 // fade out from max to min in increments of 5 points:
 for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
   // sets the value (range from 0 to 255):
   analogWrite(ledPin, fadeValue);
   // wait for 30 milliseconds to see the dimming effect
   delay(30);
 }
}

basically i need to be able to do something like this, where i program in the fade duration and brightness etc.
but as far as i can tell from my trial and error this code only works correctly on PWM pins and there aren’t enough on my board for what i need. therefore i need to see if i can run the code only on digital pins

So you expect to produce PWM on non-PWM pins? Seems like the particular way you want to fade them is a red herring, in the face of that fact.

aarg: So you expect to produce PWM on non-PWM pins? Seems like the particular way you want to fade them is a red herring, in the face of that fact.

I'm trying to produce that effect, the fading effect, with I've only seen implemented on pwm pins. if it can't be done then oh well ill have to try something else, but if i can get the fading effect thats like that on the digital pins then that would rock because there are a lot of those.

the purpose is that I'm putting the leds in a jar with the arduino controlling them individually. I'm trying to make it look like its underwater so i need some leds to stay on longer than others, some to not turn off at all. then i need some to be bright and others not to be as bright. basically I'm making a lamp with effects in a jar.

the most easyist way to do it is to use 2x74hc595 and shiftPWM library.

Take a look at my topic here http://forum.arduino.cc/index.php?topic=363116.msg2503322#msg2503322 This is for playing 13 organ notes, but you can use it as a basis for 13 blink without delay setups to have 13 PWM outputs without needing PWM pins.

spirit:
the most easyist way to do it is to use 2x74hc595 and shiftPWM library.

would you happen to have some example code showing how to use those?

i clicked the link but it brings me to a page for a “new bluetooth project”

that wasn't me, but google is a good friend.

CrossRoads: Take a look at my topic here http://forum.arduino.cc/index.php?topic=363116.msg2503322#msg2503322 This is for playing 13 organ notes, but you can use it as a basis for 13 blink without delay setups to have 13 PWM outputs without needing PWM pins.

i just clicked the link but it brings me to a page for a "new bluetooth project"

Here's the correct one http://forum.arduino.cc/index.php?topic=179761.0 Need to fix my bookmark it seems.

CrossRoads: Here's the correct one http://forum.arduino.cc/index.php?topic=179761.0 Need to fix my bookmark it seems.

Thanks :)

i just pulled up the code, so what would i have to do in order to retrofit this to match what i need it to do?

@insignia i believe you did, sorry