0

I'm trying to create a Tic Tac Toe game using the Arduino Uno. Since the Uno has a limited amount of pins to use, I am trying to see if there is a configuration that would make the project possible.

For the button detection circuit I am using a simple voltage divider and an analog pin. I made the following in a circuit simulator:

Switch Input Detection Circuit (Voltage Divider)

Now for the LEDs, since the Uno only hosts 9 pins, and we need 18, we need some sort of wizardry to get something working. I came up with the following design using the circuit simulator:

Controlling Two LEDs using One Pin

I would use 9 of these, one connected per Arduino pin. Since only one of the LEDs in each of the 9 sets should be on, this type of circuit should allow the Arduino to control all of the 18 LEDs. In the simulation I get about 5mA draw from each side (with 5v and GND).

However my problem is that the LED setup doesn't work. The lights are extremely dim. At first I simply thought that 5mA was not enough for the LED. I decided to measure the current going through the LED and found that it was about 0.8mA. What happened to my 5mA calculation? After all, isn't Arduino pin able to handle about 40mA? Am I asking for too much current?

Where have I gone wrong with this? Thanks in advance for any help.

tommis15

  • Worth mentioning, what are the specifications, or the make of your LEDs bring used – RSM Apr 25 '16 at 13:13
  • I bought them through Tayda Electronics. The spec sheet says 20mA forward, but they work when I use the GND or 5v pins on the Arduino. It just doesn't when I use the digital ones. – tommis15 Apr 25 '16 at 13:18
  • yes, those are pretty normal specs, also I wouldn't put the LED straight across 5V and GND. What I would like yo know is the voltage drop across the LED. Could you also clarify the reason why you have 3.3V on the one LED anode? – RSM Apr 25 '16 at 13:21
  • No, I am using the circuit above, but instead of a digital pin I am using the 5v and GND pin. – tommis15 Apr 25 '16 at 13:24
  • yes but why the 3.3V supply?? – RSM Apr 25 '16 at 13:26
1

I was working with it more and I found that my mistake was that I was using pin 0 and 1 to test (serial) and switching to pin 2 and above works.

  • Please accept it by clicking on the "tick" icon next to the answer. This indicates to other users that you found the solution, and it also stops Stack Exchange from periodically "bumping" your question in the hope of getting an accepted answer. Thanks for your understanding and cooperation! – sa_leinad Jan 16 '18 at 5:16
0

You should really provide more info: - your program - what exactly you are trying to achieve (you seem to be driving two leds per 'board position'. What do they represent?) and schematics.

It would also help if you measured the voltage level at the pin in both the ON and OFF state and mentioned it here.

However, one thing that should be noted (hopefully before it is too late) is that your 40mA/pin assumption is wrong. First of all, 40mA is the absolute maximum rating for one pin (i.e. the value you should stay clear of). Secondly, although one isolated pin can source or sink close to 40mA, the total of all GPIO pins should stay below 200 mA. See also http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations .

  • "The total of all GPIO pins should stay below 200 mA", yes. This is why I wanted to draw only 5mA from each pin (which would result in way under the limit). As far as my program, I have not written it because I want to hardware to work before I write. (I am using digitalWrite to test if the led will turn on). – tommis15 Apr 25 '16 at 13:33
  • How do you expect to test the hardware without running a program? And what is the voltage level of the pins? And what exactly is the meaning of each LED pair (I would expect one to represent an X and the other an O, but I can't see how your circuit would have them both off (to represent an empty position). – Alphonsos_Pangas Apr 25 '16 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.