I'm trying to figure out how to read-in a configuration to the small ATtiny10 microcontroller. I want to find out 5 or 6 different configurations, adjustable by hardware into one IO using the same firmware to make settings in the program. At the moment there are 3 DIP-switches used for this, and as you expect we need full 3 IOs. This corresponds to 8 different configurations. Can this be reduced to only using one IO? So I can switch over to an ATtiny10...

Of course I could also use the internal ADC and attach a voltage divider. Maybe it could also be purely digital. Internal Pull-Up (software switchable) has according to data sheet 20 kΩ to 50 kΩ. I come up with different possibilities to use an IO as configuration input:

  • (a) Pull-Up (high impedance) e.g. 470kΩ to VCC/VDD,
  • (b) Pull-Down (high impedance) e.g. 470kΩ to GND/VSS,
  • (c) Pull-Down (low impedance) e.g. 1kΩ to GND/VSS, if the internal pull-up resistor is on, it will be overridden during a read-in with internal pull-up set,
  • (d) Using an RC-element, see schematics,
  • (e) RC-element using another configuration.


simulate this circuit – Schematic created using CircuitLab

My idea and procedure (for instance):

  1. Set IO to input, internal pull-up on, wait a minimum of 500 ms,
  2. Read input: High on a), b), d), e) ; LOW on c) -> case (c) detected;
  3. Internal pull-up off, no wait;
  4. Read input: High on a) d) e) ; LOW on b) c) -> case (b) detected;
  5. Wait 1 ms,
  6. Read input: High on a) e) ; LOW on b) c) d) -> case (d) detected;
  7. Wait 500 ms,
  8. Read input: High on a) ; LOW on b) c) d) e) -> case (e) detected; and case (a) also detected.
  9. If d) or e) was detected set output pin to GND, else keep it as input.

In these cases, I therefore only need to mount two components on the circuit board in three designated places: (a) 0R + 470k (b) 0R + 470k (c) 0R + 1k (d) 100k + 1n (e) 470k + 100n; with all the same component size (e.g. 0603)

I hope that you can support me with further ideas?

  • 1
    \$\begingroup\$ ADC is probably best or a single UART RX line that you can send a serial message to from the PC. You can remember the setting in MCU FLASH or EEPROM \$\endgroup\$ – DKNguyen Feb 9 '20 at 22:53
  • \$\begingroup\$ @Tom - Your question of "reading multiple configuration settings using just one GPIO pin" (my summary) seems quite similar to the underlying question in this previous topic: "Add a passive hardware token using a 3.5mm jack". Even if you don't choose the same as the "accepted" answer there (1-Wire), you might find the approaches in the other answers useful too. I have not voted for yours as a duplicate of that one, but you might decide that it is, if the answers there are close enough to what you want. See what you think. \$\endgroup\$ – SamGibson Feb 9 '20 at 23:13
  • \$\begingroup\$ @SamGibson It's a nice idea to use a 1-wire device for programming, but not my intention for this question. Thank you very much for your good feedback Sam! \$\endgroup\$ – Tom Kuschel Feb 10 '20 at 17:24
  • \$\begingroup\$ @Tom - "It's a nice idea to use a 1-wire device for programming" Understood (I thought that wasn't a great "fit" for your case), but other answers include some details about how to implement RC networks, which may help with your other suggestions. So please don't focus on the 1-Wire answer to that question - I was deliberately trying to point towards the other answers. Anyway, good luck Tom! \$\endgroup\$ – SamGibson Feb 10 '20 at 17:32

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.