Analog I/O


Debounce

When a button is pressed to switch the state of the circuit, the mechanical button will tend to not switch perfectly, some times bouncing between both contact points and causing what we see in the above state diagram. There are 3 solutions to deal with this.

  1. Reading the state without debouncing countermeasures
  2. Debounce using delay() function
  3. Debounce using millis() function
Website to find out more on debounce

Analog Signals

  • Digital signals
    • Can be processed quickly
    • transition between states not smooth like analog
  • Analog signals
    • Naturally occuring
    • Do not have discrete voltage, transitions smoothly
    • Hard to process
  • Conversions
    • Analog Digital Conversion(ADC)
    • Digital to analog

Analog Input Arduino

The arduino Uno has 6 analog inputs (A0~A5). Each input is connected into a 10bit(bit=base2, 10 refers to power, Thus 1024 in decimal count.), ADC which has a Vcc of 5V. Analog Inputs reads values between (0~1023) which can be adjusted using a variable resistor.

Analog Output Arduino

The arduino Uno like any other computer reads digital data, thus to get a analog output, we need to use a DAC. Because the Arduino does not have a built in DAC, we need to use Pulse Width Modulation(PWM). The arduino has 6 PWM output in the digital ports marked as "~". These include ports 3, 5, 6, 9, 10 and 11.