Wagner Lipnharski of UST Research Inc. says:
An easy way to have a key and a indicator led connected to a single microcontroller port pin is connect the LED (anode) with a resistor (330 Ohms) to +VCC (+5Vdc) and the cathode to the port pin, the key goes to the same port pin to ground via another resistor (100 Ohms). By this way, whenever you want to read the key, just flip the port pin to up level and read it. The LED can serve as an indicator of the function selected by the key. Suppose the LED is off (port pin high), pressing the key will turn on the LED (3/4 brighness) and will drop the port pin level, reading the port pin would indicate a low level, so it would means "key pressed", then your software will "latch" that information flipping the port pin to low level (LED goes to 100% brightness) indicating key was read as "pressed". A 49ms low level and 1ms high level to read the key is enough to keep the LED as brigh as possible and run the debounce routine. After the debounce, pressing the key again would signal the software to deactivate the LED. It would works as a flip-flop switch with indicator, with a single port pin. The 100 Ohms resistor (that creates the 3/4 LED intensity) is to inform you when the software effectivelly read the key pressed and confirmed the "pressed" status by bypassing the 100 Ohms resistor to ground.
|file: /Techref/io/1wledsw.htm, 1KB, , updated: 2007/6/15 12:11, local time: 2022/5/16 02:04,
|©2022 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://piclist.com/techref/io/1wledsw.htm"> Hardware Input/Output 1 wire LED and switch</A>
|Did you find what you needed?|
PICList 2022 contributors:
o List host: MIT, Site host massmind.org, Top posters @20220516
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to piclist.com!