P. 1
Introduction to Practical Electronics Microcontrollers and Software Design

Introduction to Practical Electronics Microcontrollers and Software Design

|Views: 508|Likes:
Published by Stefanvnv
An Introduction to
Practical Electronics,
Microcontrollers and
Software Design
An Introduction to
Practical Electronics,
Microcontrollers and
Software Design

More info:

Published by: Stefanvnv on Feb 22, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/19/2013

pdf

text

original

There is a very convenient way of reading multiple switches with your
microcontroller and only use 1 input port.

By making up a long voltage divider as in this diagram and connecting its
output to a microcontroller ADC pin, the voltage will change to a different
voltage output for every different switch press. This happens because the
voltage divider changes the number of resistors in the voltage divider for
every different switch press

If no switch is pressed then there is no voltage divider as all the resistors
R21 to R31 are unconnected. The input voltage to the ADC will be Vcc
(5V) and the ADC reading will be max (1023).

If S1 is pressed then othere is also no voltage divider, however the adc
input is now connect to ground (0V) and the adc reading will be 0.

If s2 is pressed there will only be two resistors in the voltage divider and
the output will be
Vout =

= 0.5V (ADC reading of 0.5/5*1023 = 102)

If S3 is pressed then only 3 resistors will be in the voltage divider and the
output will be
Vout =

= 0.667V (ADC reading of 0.667/5*1023 = 136

If S4 is pressed then only 4 resistors will be in the voltage divider and the
output will be
Vout =

= 0.75V (ADC reading of 0.75/5*1023 = 153

The emerging patterns here are that the output is becoming larger and
larger, and the differences between the steps are becoming closer and
closer. Note the pattern in the voltages 1/2Vcc , 2/3Vcc, 3/4Vcc, 4/5Vcc,
5/6Vcc, 6/7Vcc....
This means that there is a limit to the number of switches that can be put
in this type of circuit.

314

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->