Analog Read/Write

  • Analog pins don't require pinMode -- they are fixed
  • analog read pins are on a separate set up pins
  • analogue write pins (PWM pins) are on 9, 10, and 11
  • analogWrite takes a pin and a value (but the value must be between 0 and 255)
  • analogRead takes a pin (must be numbered from the analog pins) and returns a value 0 - 1023
    • This is four times larger than analogWrite
    • The number corresponds with the voltage
      • 0 is 0V
      • 1023 is 5V
    • You can test your sensors and see what voltage that give off with a multimeter, then build your circuit around that
    • or check the output from serial and calibrate your application that way

Copyright Mike Edwards 2006-2009. All content available under the Creative Commons Attribution ShareAlike license, unless otherwise noted.