Pages: [1]   Go Down
Author Topic: Analog control of 15 outputs - Beginner question  (Read 312 times)
0 Members and 1 Guest are viewing this topic.
Arizona
Offline Offline
Newbie
*
Karma: 0
Posts: 27
"Geeks rule the world; nerds rule the World of Warcraft." -Anonymous
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm setting up a project using the Arduino and I'm the very early stages of design. I was just wondering if someone could help me out with some basics.

What are some reading materials I could be pointed towards to help with a project that I need the following for. I plan on using the Arduino Pro Mini due to its light weight and small size for the project, which will be wearable. I need to, by the end of my project, have the ability to do the following things:

1. Get full analog control of 15 individual outputs (5 RGB LEDs)
2. Have 4-5 digital inputs
3. Create a system for simple syntax of this control (LED#, color, brightness)

If someone could just point me towards a website or book, that would be fine. I'm just not sure where to get started since many of the materials I've been finding don't have a lot of info on such a specific design for obvious reasons. Thanks a ton to anyone who helps. Also, I would like to refrain from using preexisting shields as I will be using the Pro Mini and I need this design to be compact and simple.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

For that many outputs you need an external chip. A popular one is the TLC5940 google that for help with it.
Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As Grumpy_Mike you would certainly need some additional hardware to handle all of those outputs.That's a separate task to deal with.  smiley-roll

Setting up the digital input won't be a problem. Here is an example of setting up a digital input using a button and a 10K resistor:  
http://arduino.cc/en/tutorial/button smiley

Or if you don't have a 10K resistor you could use the internal pull-up resistor right on the Arduino which would save up some wiring. Here is a video tutorial:
http://youtu.be/jJnD6LdGmUo

Also be aware that Arduino Mini has only 6 PWM outputs and you need 15 of them which means you would need some extension for that too. That's something hard for me to explain since I have no good knowledge in that.  smiley-roll-sweat

I could guide you through the  "system for simple syntax of this control" as I like it how you call it, very formal.  smiley-wink

First of all, you could create your own function. Here is a link to it if you won't understand my explanation:
http://arduino.cc/en/Reference/FunctionDeclaration

So you want: (LED#, color, brightness). Lets create a function and call it "rgbControl" and let it control some of the attributes.
Note: I will separate the color section into three sections, R, G and B. I will remove the LED number in you proposal but you can add it any time

Code:
void  rgbControl(int r, int g, int b, float brightness){
  // let's say the RGB led has its RGB pins on number 1,2 and 3
  // Input the brightness in percentages
  analogWrite(1,(r*brightness/100)); // lets set its red value
  analogWrite(2,(g*brightness/100)); // lets set its green value
  analogWrite(3,(b*brightness/100)); // lets set its  blue value
}

Put this code before or after the loop() function (not in the function). And in the loop() itself you could write something like

This will give you a red at a 50% brightness:
Code:
rgbControl(256,0,0,50);

This will give you a green at a 80% brightness:
Code:
rgbControl(0,256,0,80);

This will give you a red at a 100% brightness:
Code:
rgbControl(0,0,256,100);


The final sketch may look something like:
Code:

void setup () {
}

void loop () {
  rgbControl(256,0,0,50); //This will give you a red at a 50% brightness:
  rgbControl(0,0,0,0);    //Set values to off
  rgbControl(0,256,0,80); //This will give you a green at a 80% brightness:
  rgbControl(0,0,0,0);    //Set values to off
  rgbControl(0,0,256,100); //This will give you a red at a 100% brightness:
  rgbControl(0,0,0,0);     //Set values to off
}
void  rgbControl(int r, int g, int b, float brightness){
  // let's say the RGB led has its RGB pins on number 1,2 and 3
  // Input the brightness in percentages
  analogWrite(1,(r*brightness/100)); // lets set its red value
  analogWrite(2,(g*brightness/100)); // lets set its green value
  analogWrite(3,(b*brightness/100)); // lets set its  blue value
}

I hope this will get you started. If you have questions just ask smiley
« Last Edit: March 18, 2013, 12:03:25 pm by mixania » Logged

Arduino Uno R3
Mac OSX Lion


Pages: [1]   Go Up
Jump to: