Pages: [1]   Go Down
 Author Topic: Use a POT to control a time limit  (Read 250 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 11
 « on: November 12, 2012, 08:57:50 am » Bigger Smaller Reset

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)

 Logged

Offline
Edison Member
Karma: 114
Posts: 2205
 « Reply #1 on: November 12, 2012, 09:07:15 am » Bigger Smaller Reset

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.
 Logged

Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #2 on: November 12, 2012, 09:15:09 am » Bigger Smaller Reset

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.
 Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Offline
Newbie
Karma: 0
Posts: 11
 « Reply #3 on: November 12, 2012, 09:20:04 am » Bigger Smaller Reset

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
 Logged

Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #4 on: November 12, 2012, 09:30:57 am » Bigger Smaller Reset

You're over-thinking - user-defined interrupts are not part of this problem.
 Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

South Texas
Offline
God Member
Karma: 8
Posts: 976
 « Reply #5 on: November 12, 2012, 11:44:27 am » Bigger Smaller Reset

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

Offline
Newbie
Karma: 0
Posts: 11
 « Reply #6 on: November 13, 2012, 04:46:40 pm » Bigger Smaller Reset

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
 Logged

Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #7 on: November 13, 2012, 04:50:56 pm » Bigger Smaller Reset

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.
 « Last Edit: November 13, 2012, 04:53:16 pm by AWOL » Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Offline
Newbie
Karma: 0
Posts: 11
 « Reply #8 on: November 13, 2012, 04:56:50 pm » Bigger Smaller Reset

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
 Logged

Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #9 on: November 13, 2012, 04:58:14 pm » Bigger Smaller Reset

How do you normally divide something?
 Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Offline
Newbie
Karma: 0
Posts: 11
 « Reply #10 on: November 13, 2012, 04:59:48 pm » Bigger Smaller Reset

How do you normally divide something?
by using " / "
 Logged

Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #11 on: November 13, 2012, 05:01:55 pm » Bigger Smaller Reset

So what's the problem?