0
Offline
God Member
Karma: 0
Posts: 507
Arduino rocks
|
 |
« on: December 14, 2007, 02:00:25 pm » |
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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #1 on: December 14, 2007, 03:10:06 pm » |
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
God Member
Karma: 0
Posts: 507
Arduino rocks
|
 |
« Reply #2 on: December 14, 2007, 06:50:23 pm » |
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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #3 on: December 15, 2007, 07:37:55 am » |
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
God Member
Karma: 0
Posts: 507
Arduino rocks
|
 |
« Reply #4 on: December 15, 2007, 01:09:06 pm » |
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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #5 on: December 15, 2007, 05:57:39 pm » |
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
God Member
Karma: 0
Posts: 507
Arduino rocks
|
 |
« Reply #6 on: December 16, 2007, 02:39:47 pm » |
aha, thats what it is, ok i see it, ill look at it and try to copy the code into mine, thanks!
|
|
|
|
|
Logged
|
|
|
|
|
|