RGB LEDs do i need to use all the color pins?

Hey guys just a quick question, im trying to make a tic tac toe game with LEDS and HC-06 bluetooth controller, and i was wondering due to the ports amount on arduino, i'd need 27 ports to setup 9 RGB LEDs, but it came to me that i dont need all 3 colors for my game, i have only 2 players. The reason why im asking this is because i haven't used a RGB LED to this momment, just the regular ones. Therefore, my question is do i need to use all the pins from the LED to occupy my arduino outputs or can i just connect the ones i need and it'll work perfectly?

Are you planning on using MAX7219 to control the 9 RGB LEDs?

If so, why would you need 27 pins?

Look at ShiftPWM Library, for controlling many LEDs

You can use just 2 colors of each RGB LED. Simple way is to use 18 outputs from the Arduino to drive the 9 Red and 9 Green, say, LEDs.
If the LEDs will be only 1 color, say Red or Green, then you can use a single resistor per RGB LED on its common pin for current limiting.
If you plan to turn on both LEDs, say to get Amber from Red & Green, then you would need a resistor per LED on the unique leads.

You could also drive the 18 leads from 3 shift registers and only use 3 pins from the Arduino to drive the shift register (clock, data, latch). That would provide 24 outputs, you can have some status indicators for the game as well or something.

CrossRoads:
You can use just 2 colors of each RGB LED. Simple way is to use 18 outputs from the Arduino to drive the 9 Red and 9 Green, say, LEDs.
If the LEDs will be only 1 color, say Red or Green, then you can use a single resistor per RGB LED on its common pin for current limiting.
If you plan to turn on both LEDs, say to get Amber from Red & Green, then you would need a resistor per LED on the unique leads.

This is very interesting and much of what i am looking for, they will be green or blue. since its a tic tac toe game, they light up in different colors for example: LED1 blue, LED2 RED, LED3 BLUE, until someone wins the game. But what worries me is the amount of slots that i can use in arduino. Because from what i know of, RGB uses 4 pins, which 1 is GND and other 3 are colors, but i will only need 2 of them.

How do i do this drive thing?

It's already been explained that if you don't want to connect to connect up the red LED if you don't want to. You don't need a separate ground for each LED. Just connect them all to the same ground.

"Drive" just means turning the LED on or off.

Really if you just plug the thing in and get working it will be clear soon enough. But don't forget the current limiting resistors!

pert:
It's already been explained that if you don't want to connect to connect up the red LED if you don't want to. You don't need a separate ground for each LED. Just connect them all to the same ground.

"Drive" just means turning the LED on or off.

Really if you just plug the thing in and get working it will be clear soon enough. But don't forget the current limiting resistors!

Yea i was looking for tips on how to save output ports other than the answer

OK, then do some research on the MAX7219, as already recommended by ieee488.

Another option would be to use addressable LEDs such as APA102 or WS2812. You can control hundreds of them from one or two pins on your Arduino.

If you don't need PWM to dim the LEDs then you could use a shift register.

alright i will look into, thank you all guys for your time to help me!

puelon:
[...]which 1 is GND and other 3 are colors[...]

That's a dangerous assumption :wink: You have two kinds* of common RGB leds. Common anode (1 pin for positive) and common cathode (1 pin for negative). The first is probably the most common. You can use both, only with a common anode you connect the common to Vcc and the color pins to an Arduino pin. They will turn on if you set the output to LOW. Just like with buttons newbies tend to find this confusing but that why we call it HIGH and LOW and not ON and OFF :wink:

And about resistors, you probably want to different values for the two colors because of the (possible) different forward voltage of the colors and thus the difference in brightness you would get if you use a single color.

Another option would be to multiplex the leds. That would only require 9 + 2 = 11 pins. And if you use a low current for the leds, 2mA for a modern led probably is more then bright enough, you don't even need a transistor. And you can even make those 2 pins PWM pins and be able to dim the play field as well. But, the software gets a bit more complicated to do the multiplexing. But it's not rocket science :wink:

  • Common RGB as in, 4 legs, no controllers etc

if you haven't bought leds yet, there are bicolor leds. But i'd recommend using smart leds anyway, much less work for soldering and coding.