Using a Pot to control the brightness of a LED

at uni we were set a task about how to control the brightness of a LED using a POT now although i'm sure i know howto do it, i've got a bt of a memory blank;

this is the code i have so far;

define POT1 0

define POT2 1

define LED1 5

define LED2 6

void setup() {

}

void loop() { analogWrite(5, analogRead(0)/4); }

what do i need, please don't give me excat code (not gonna learn that way) just tell what i need to do, eg (you to initalise something)

Does your code work? I can't see a problem, but maybe you've wired it wrong. For extra points, you may want to use those nice names you've given the pins.

AWOL: Does your code work? I can't see a problem, but maybe you've wired it wrong. For extra points, you may want to use those nice names you've given the pins.

unfortunaley i don't have a cable with me so i can't check it, to me something seems missing

What do you think is missing? (apart from the cable)

Adc a pin and then use it to control the duty cycle of the pin that is driving your led.

Ah! You forgot the code tags.

dhenry: Adc a pin and then use it to control the duty cycle of the pin that is driving your led.

ok, now i forget how to do that, thats what i get for doing this late at night :)

ok, now i forget how to do that, thats what i get for doing this late at night

It's the only executable line in the code you posted.

AWOL:

ok, now i forget how to do that, thats what i get for doing this late at night

It's the only executable line in the code you posted.

oh derp, so if i wanted to control more LEDs using another POT would it be the same kinda code?

oh derp, so if i wanted to control more LEDs using another POT would it be the same kinda code?

Yes, you just change the analog channel and pin number of course.

oh derp, so if i wanted to control more LEDs using another POT would it be the same kinda code?

I think you are supposed to connect the pot to the Arduino, not smoke it.

dhenry: Adc a pin and then use it to control the duty cycle of the pin that is driving your led.

As usual from dhenry a beautiful description of what you have already done. Another fantastically useful post there. Gods aren't what they used to be are they.

You are only controlling LED1 with POT 1.

You should add another line to control LED2 with POT 2.

Remember you need a resistor in series with the LED - (yes you do dear henry )

I haven’t seen any wiring discussion - one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?

one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?

I thought for sure you'd know that.

PaulS:

one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?

I thought for sure you'd know that.

i'm using a Arduino board all of the wiring has already been done, even if it hadn't done electronics for 4 years so woulda doen that first :P

Tomsta:

PaulS:

one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?

I thought for sure you'd know that.

i'm using a Arduino board all of the wiring has already been done, even if it hadn't done electronics for 4 years so woulda doen that first :P

All the wiring is done, you posted an (apparently) working piece of code...what exactly was the problem?

fungus:

Tomsta:

PaulS:

one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?

I thought for sure you'd know that.

i'm using a Arduino board all of the wiring has already been done, even if it hadn't done electronics for 4 years so woulda doen that first :P

All the wiring is done, you posted an (apparently) working piece of code...what exactly was the problem?

beacuse i thought i left something out, as i was thinking there was no way the programme could be that easy (turns out it could be)