0

I would like make educational shield for playing with Arduino, where (at least couple of) pins would be connected to grounded switches (so could be configured as INPUT, or INPUT_PULLUP a digitalRead() in the program) and at the same time there would be two LEDs (say GREEN for 0 and RED for 1) to indicate the status of the switch (pressed or free).

And also there is possibility to program the PIN to OUTPUT and make the LEDs just shine with digitalWrite() (HIGH for red, LOW for green).

But as it can be used by beginers, I would like to make sure, that even if the PIN is HIGH and button is pressed (so connected to GROUND), then no harm happens to the PIN.

As it would be all on the shield, I do not have to care about other sources of power. And the error condition (OUTPUT vs switch pressed) can be UNDEFINED (that means result in none, one or both LEDS to shine full/part, I do not care).

Is it possible to arrange it with just some resistors, or I have to decouple one/both the LEDS with transistors to enhance the signal, separate them from shining both with open swith (and pullup) and protect the pin?

(creating PCB is not problem for me, I just want make it safe for childs to play with and have it ready without sticking wires to breadboard (and possibly shortcut power or something like that) for couple of first "projects")

(Here is the IDEA, but the editor filled some values, ignore them please)

schematic

simulate this circuit – Schematic created using CircuitLab

Thank you for helping me out :)

  • 1
    Change R3 to at least 250 Ohm, so the current from the pin will not exceed 20mA when it's HIGH and the button is pressed. Make sure D1 has a high forward voltage (so blue or white, instead of red). Have you really run out of pins on your uC? I hope you are not expecting the kids to program these boards, as this setup already make my brain hurt a bit, thinking of how to program it. – Gerben Jan 3 '17 at 19:20
  • My little cousin IS programing this board, so my expectations have some base. And I do program those boards too and such shield make it easier to test some teories, as I can simply set leds as I wish and see result "just now", while still able to attach osciloscope to those pins and see exactly, what is there. It is not just "run out of pins", but more like "having it easier to setup something fast and debug it safely". Previous version of the shield uses ProMini, 4 switches and 8 leds, but it lot of setups requires another numbers of inputs/outputs, or other pins (like I2C, or PWM or so) – gilhad Jan 3 '17 at 20:25
  • @Gerben : like in (download.gilhad.cz/minishield1.jpg) (download.gilhad.cz/minishield2.jpg) that I currently use also to access I2C EPROM and I am developing H-bridge driven by that too (and directed over I2C from another shield with those buttons, but I would like to have more buttons just now on "master" and more leds on "slave" and do not want to create different shield for each case, as I will make full PCB for result and use those shields as base for next project ) – gilhad Jan 3 '17 at 20:43
  • 1
    As Gerben said, use high brightness LEDs, since red and green standard ones will light up both when you set it in input mode. Then increase the resistor, and test if the leds light up enough. Remember to keep the voltage in the node below 1.5V otherwise you won't get a clean 0. Maybe setting all the resistors to 200 will be fine, just test with the actual leds and see if the light is enough. And teach the childs not to set an output and force it ;) – frarugi87 Jan 4 '17 at 10:11
  • 1
    Or better put four resistors in a cross-shape. Two 3V leds and four 100 ohm resistors, one towards each led, one for the button and one for the pin. The leds will have 10mA of current, and in the case of a short circuit you will get 25mA out of the pin, which is bearable by it (of course don't do that on more than 1 pin, otherwise you'll destroy it). – frarugi87 Jan 4 '17 at 10:13

Your Answer

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

Browse other questions tagged or ask your own question.