Go Down

### Topic: Use a POT to control a time limit (Read 3378 times)previous topic - next topic

#### Tomsta

##### Nov 12, 2012, 02:57 pm
I wanna use a POT to control the time of a certain function and for the life of me i can't work out how to get the POT to control the time could someone try to explain it to me (no code if you can help it)

#### dhenry

#1
##### Nov 12, 2012, 03:07 pm
Forget about the pot portion: can you control the time of a certain function?

Once you  have that figured out, try to read the pot's value and then use that value to control the time of a certain function.

#### AWOL

#2
##### Nov 12, 2012, 03:15 pm
The analogRead will return a value in the range 0 .. 1023.
If this isn't a convenient range of values, you could use the "map" function to get it to more convenient units, or, as you did in your LED dimmer, just use simple arithmetic.

Plug the resulting value into the "interval" variable in blink-without-delay.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### Tomsta

#3
##### Nov 12, 2012, 03:20 pm

The analogRead will return a value in the range 0 .. 1023.
If this isn't a convenient range of values, you could use the "map" function to get it to more convenient units, or, as you did in your LED dimmer, just use simple arithmetic.

Plug the resulting value into the "interval" variable in blink-without-delay.

that's what i ended up doing but not sure if it works (as i have no cable can't tell if it's working) and i don't wanna use interputs in my programme just yet

#### AWOL

#4
##### Nov 12, 2012, 03:30 pm
You're over-thinking - user-defined interrupts are not part of this problem.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### kf2qd

#5
##### Nov 12, 2012, 05:44 pm

No need for interrupts  or other complex processing. Every time through loop read the POT and update the variable with the delay time.

#### Tomsta

#6
##### Nov 13, 2012, 10:46 pm

No need for interrupts  or other complex processing. Every time through loop read the POT and update the variable with the delay time.

no idea how to scale that value, i've used "analogeRead" but doesn't work

#### AWOL

#7
##### Nov 13, 2012, 10:50 pmLast Edit: Nov 13, 2012, 10:53 pm by AWOL Reason: 1
Quote
i've used "analogeRead" but doesn't work
And that means what exactly?
(The compiler expects you to spell it correctly, if that's what you meant)

Scaling usually involves an arithmetic function.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### Tomsta

#8
##### Nov 13, 2012, 10:56 pm

Quote
i've used "analogeRead" but doesn't work
And that means what exactly?
(The compiler expects you to spell it correctly, if that's what you meant)

Scaling usually involves an arithmetic function.

using the "analogeRead()" read in the pot value, but i don't know what to devid the value by to get the scale right

#### AWOL

#9
##### Nov 13, 2012, 10:58 pm
How do you normally divide something?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### Tomsta

#10
##### Nov 13, 2012, 10:59 pm

How do you normally divide something?

by using " / "

#### AWOL

#11
##### Nov 13, 2012, 11:01 pm
So what's the problem?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Go Up