Analog on the Arduino int k; // integer = 16 bits k = analogRead(1); Analog volts value (0V → 5V)...
-
Upload
jeffry-sparks -
Category
Documents
-
view
226 -
download
0
Transcript of Analog on the Arduino int k; // integer = 16 bits k = analogRead(1); Analog volts value (0V → 5V)...
Analog on the Arduino
int k; // integer = 16 bitsk = analogRead(1);
Analog volts value (0V → 5V)returns from 0 to 1023 into “k”
(10 “bits” = 1024 values)
Analog range:
● dynamic range● precision● accuracy – repeatability● calibration for accuracy?
Resolution
2 bits 0 - 3
8 bits 0 – 255
10 bits 0 – 1023
16 bits to 65000
32 bits to over 4 billion
Resolution / precision
5 volts
1024 possible measurements
So resolution = 5000 / 1024 millivolts
Ie about 5 mV
● Pullups and Voltage Dividers
READING REFERENCE DOCUMENTS
LDR
THERMISTOR “NTC”
LM35 Temp SENSOR
LDR
“50k OHM Thermistor NTC 3950 MF52AT”
Accurate temp sensor LM35
But analog sensor resolution could be better matched than this
● Modulo division – remainders
● Long integers – preventing rollover errors
PWM to LEDs(remember that?)
PWM output (dimming a LED) used
analogWrite(3, 150); // pin d3, 150/255 bright
This was “8 bit” resolution (0 - 255)
Industrial
Common industrial analog signalling has been
4 – 20 mA full range.
How could Arduino handle that?
Why start from 4 mA, not 0mA?