Pages: [1]   Go Down
Author Topic: potentiometer's to control awsomness!  (Read 769 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
God Member
*****
Karma: 0
Posts: 507
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have an idea, and it'll be awsome!! heres what the situation is: we have 2 potentiometers, and 3 leds (RGB) and a 7 segment display. so we could do this: we can use one potentiometer  to control the mode ( either mode 1:led 1, mode 2:led 2, or mode 3:led3 ) and use the second potentiometer to controll the brightness of each led, and put em all in pwm obviously. And use the 7 segment display to tell us what mode were in.

so we turn one potentiometer, and itll tell us which led were controling, and then we use the second potentiometer to tell us the birghtness of the led's, and the mode is displayed on the 7 segment display.
but i need somebody who can code this up for me, cuz i think i can only code the 7 seg display, so any one up for the challenge??
thanks in advance!
-big93
« Last Edit: December 14, 2007, 02:02:07 pm by big93 » Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is fragment to select the led that can get you started:

  #define POT_PIN      1  // the analog pin that the post is connected to
  #define NBR_OF_MODES 3  // the number of leds
  
   int potvalue = analogRead(POT_PIN);    // read the pot position
   int mode  = potvalue /(1024 / NBR_OF_MODES);  //  divide 1024 max pot value by number of modes

in this example,  mode will range between 0 to 2 as the pot is rotated:
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 507
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this gives me 3 modes right?

0, 1, 2?

cuz if thats the code for mode changing, i think i might be able to code the rest myself, wait except brightness, and controlling it with the potentiometer... can u code that also please?
thanks mem!
big93
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a read about analogWrite() and see the 'fading led ' example sketch  in the IDE.

All you should need to do is divide the value returned from the pot (max 1024) by 4 and feed it into analogWrite.  Have fun!
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 507
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lol sorry but i gotta throw a noob question at you.... whats IDE?

sorry, uve been telling me to go there for a while and i'm like "hmm, maybe its the tut section? "
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 IDE: Integrated Development Environment. It is the program called arduino.exe that you run to create and compile sketches. In the main menu, see File ->Sketchbook->Examples->Analog->Fading
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 507
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

aha, thats what it is, ok i see it, ill look at it and try to copy the code into mine, thanks!
Logged

Pages: [1]   Go Up
Jump to: