gsuberland,
@gsuberland@chaos.social avatar

today's fun tip: you can detect the state of two switches or buttons using a single input pin on a microcontroller that supports internal pullups (which is most of them) as long as you don't need to detect both being pressed at once.

to read the button state, turn the internal pullup off, read the pin, turn the pullup on, and read the pin again. if the value changed, no button is pressed. high both times = top button, low both times = bottom button.

try it: https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgpABZsKBTAWjDACgAncMFEYw7rzAYBVSvDYBnQeBEyUNKlQgAzAIYAbSQzYAlGfxmEaUU4upKo0BGwDu88ywEKlnEE5Av3YAdkJ5TFDQJAHNvX39wkGw8E1d7Dy8mPCovSCl3FM9HLNw48BB1LR0uZKo8zPLI1OC2MLLoyIaY-PTpBqSs4VECou03Bu7Kvh6guD1hwwbjUypzJEsYG3tWXi8fVPN0gFlwQk3U-GzLFGs2AA9wFAhhcjHwLJMfEABLADsAFwYON80AHUkAAcAK4aDTAwFsABGIFyaxInjIUAu4BoARQ9DQ8No2RA2wAwgBVNhAA

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Electronics
  • DreamBathrooms
  • ngwrru68w68
  • cubers
  • magazineikmin
  • thenastyranch
  • rosin
  • Durango
  • InstantRegret
  • Youngstown
  • slotface
  • khanakhh
  • kavyap
  • mdbf
  • tacticalgear
  • JUstTest
  • osvaldo12
  • tester
  • modclub
  • normalnudes
  • everett
  • GTA5RPClips
  • ethstaker
  • Leos
  • anitta
  • megavids
  • cisconetworking
  • provamag3
  • lostlight
  • All magazines