Embedded Systems & Firmware

A switch alone is connected to a microcontroller input pin, with no pull-up or pull-down resistor. What can happen while the switch is open?

  1. AThe pin always reads 1
  2. BThe pin floats at an undefined level, and noise makes it read 0 and 1 erratically
  3. CThe microcontroller loses power
Show answer and explanation

Answer: B. The pin floats at an undefined level, and noise makes it read 0 and 1 erratically

A CMOS input draws almost no current, so with nothing connected its voltage is undefined and noise from nearby signals or even a hand nearby changes the reading. Sitting at an intermediate voltage can also cause shoot-through current in the input circuit, raising power consumption. With a pull-up resistor to the supply, the pin reads 1 when the switch is open and 0 when it closes to ground. Most microcontrollers offer built-in pull-ups.

  • A. With nothing connected, the value is undefined.
  • B. Correct. A resistor is needed to hold it at a defined level.
  • C. Power is not cut.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. When using a microcontroller GPIO (general-purpose input/output) pin, what must be configured first?
  2. What is the phenomenon called in which a mechanical switch's contacts bounce, turning on and off many times in a short period when pressed?
  3. Which is the most suitable way to remove switch bounce in software?
  4. A timer counts a 16 MHz clock divided by 16 with a prescaler and raises an interrupt every 1000 counts. What is the interrupt interval?
  5. A PWM signal has a period of 1000 counts, with the output high (1) for 250 counts of each period. What is the duty cycle?