Using limited I/Os effectively

Hi my name is Cody, have had an Arduino Uno for a couple years, but still an amateur building on my skills every other month or so.

Ik most the basics and am trying to make a more interactive program besides just blinking lights, etc. I have a handful of sensors, particularly a joystick. I got it all setup and can view the X/Y on the monitors and even have IF statements to tell me what quadrant the joystick is in like a TIC TAC TOE board I.e. (upper l, upper middle, upper right, etc.).

My project idea is to use 9 LEDS and have them turn on/off as I move the joystick around just as a practice programming joystick movement. I haven’t wired the LEDs yet, but initial thought was to hard wire each LED to a PIN and IF the joystick is in that quadrant to turn the LED to HIGH… overall not to complicated, except for the fact that I don’t think I have enough pins w/ the joystick or if I do none will be left for any other functionality I.e. another sensor, LCD, etc.

Is there a smarter way to tell an individual pin to turn on/off without using 1 pin per LED?

I was thinking of trying to give each row & column a number 1-3 (total of 6 pins: 3x + 3y) and say it’s in the upper right square send a signal through all 3 right hand squares, but only send the signal through the top row of squares i.e. where the 2 signals intersect would be the only square getting full power (don’t mean changing the power output per say, though maybe that is an option… just mean if that square gets 2 YES indicators to turn on)

So if you made it a 4x4 grid instead of needing 16 pins you’d only need 8?

Ik this is a very roundabout question for a very simple project, but feel I have seen people get more functionality out of an UNO than just a joystick and 9 LEDs, but unsure how I could wire it without the number of pins I’m using going through the roof or needing multiple boards.

Any advice or suggestions appreciated!

Edit: searching on YT I have seen things for “chasers” and Cubes, but think the difference between these and what I want to do is individual control… I.e. a chaser, all the LEDs are getting the same input, but delayed… think I similar thing is done with the cubes so even though it’s an 8x8x8… not every LED is getting it’s own signal… still investigating

You could Google "charlieplexing"

1 Like

There are also LED matrix that use a MAX7219 to drive them. They only use 3 or 4 pins to control 64 (or way more) LEDs.

1 Like

Yes I think this is what I need to learn! Thank you

Okay I see what you are saying, will probably grab one of those for that is the functionality I am looking for, but was trying to wire it in a more basic setup… I mean basically trying to make that myself using a breadboard, LEDs and resistors… reinventing the wheel but as a learning exercise

Aliexpress links; Single:

Quad:

Green is nicest. :grin:

It is never too early to discover and start working with smart LEDs.

Neopixels are one kind. Google it. You can have a large number of LEDs and run them from one pin… no additional hardware except a capacitor and a resistor.

Also I mention the wokwi.com simulator, where you can wire up all kindsa stuff without waiting for the delivery man to bring new supplies and without burning your fingers.

a7

Another method to utilize more outputs with less pins is using a SIPO shift register such as the SN74HC595. There are some good tutorials on Youtube for it, but you can drive 8 outputs using 3 pins. I used it to drive my 8 channel relay board with 3 pins, and it is very reliable so far.

3X3 == 9 LEDS, but 3X3 matrix needs only 6 outputs:
3 Outputs for x-cord
3 Outputs for y-cord

image

DO NOT FORGET THE CURRENT LIMITING RESISTORS (3)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.