analogRead() and analogWrite()
To start with analogRead(PIN_NAME) allows you to read a voltage from 0-5 volts (default) and gives a value from 0-1023. This means for every 4.9 millivolt (approximately) you get one from analogRead().
analogWrite() is a function available only on certain digital pins called the PWM pins. If you look closely to the digital pins you will find some ports with "~" symbol before them. Only these pins support analogWrite(). The syntax for using analogRead() is analogRead(PIN, VALUE) where value is an integer from 0-255 (0 for 0 volts and 255 for 5 volts). analogRead() can be used to control brightness of L.E.Ds, speed of motors etc.
No comments:
Post a Comment