Advertisement

Zibb

Design Idea

Three-state switch interface uses one microcontroller pin

A single microcontroller I/O pin senses the state of a three-position switch.

Kartik Joshi, Netaji Subhas Institute of Technology, New Delhi, India; Edited by Charles H Small and Fran Granville -- EDN, 2/21/2008

Human interfaces for electronic gadgets sometimes require three states for control. A single-axis joystick has states to define motions to the right, to the left, and with no motion. Similarly, a timer has control buttons that allow the timer to increment, decrement, and remain untouched. Engineers usually create these interfaces by using two independent pushbuttons, requiring two microcontroller pins. This Design Idea presents a way to sense three states of an SPDT (single-pole/double-throw) switch with a center-off state, using only a single pin of Atmel’s ATmega8 microcontroller (Reference 1 and Figure 1). Listing 1 is a simple program for the circuit.

The status of the pin of the microcontroller depends upon values of the DDR bit, the port bit, and its external connection. The microcontroller’s pin connects to ground using pulldown resistor R1 with resistance, typically, of a few hundred kilohms to impress the high-impedance state on the pin. You set the DDR register to zero. When the user toggles the switch to Position 1, the pin connects to VDD through resistor R5, and the pin bit is one, regardless of the value of the port bit. When the user toggles the switch to Position 3, the pin is grounded, and the pin bit is zero, regardless of the value of the port bit. In the center-off state, the pin bit follows the port bit. Table 1 summarizes the states of the pin for different values of the port and the external input.


Reference
  1. ATmega8/ATmega8L 8-bit AVR with 8K Bytes In-System Programmable Flash,” Atmel Corp, 2007.


Reed Business Information Resource Center

Featured Company


Related Resources

ADVERTISEMENT

ADVERTISEMENT

Related Content

 

By This Author

There are no additional articles written by this author.


ADVERTISEMENT

Knowledge Center


Events

Phosphor Global Summit 2010
Dates: 3/23/2010 - 3/25/2010
Location: San Diego, CA

Multicore Expo
Dates: 4/26/2010 - 4/29/2010
Location: San Jose, CA

5th Fraunhofer IMS Workshop
Dates: 5/4/2010 - 5/5/2010
Location: Duisburg/Germany

Packaging Technology and Metallurgy Course
Dates: 5/26/2010 - 5/28/2010
Location: Malaysia

Oxford University High-Speed Digital Design Short Course
Dates: 6/22/2010 - 6/23/2010
Location: Oxford, United Kingdom

Submit an EventSubmit an Event




Technology Quick Links

EDN Marketplace


©1997-2010 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy