판매사이트 : https://www.devicemart.co.kr/

 

PDF: 센서 스펙

D7-CdS-e.pdf
0.26MB

 

 
 
analogRead()
Description


Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. The input range and resolution can be changed using analogReference().


It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.


Syntax


analogRead(pin)


Parameters


pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)


Returns


int (0 to 1023)
analogWrite()


Description


Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz. Pins 3 and 11 on the Leonardo also run at 980 Hz.


On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11.


The Arduino Due supports analogWrite() on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs.


You do not need to call pinMode() to set the pin as an output before calling analogWrite().


The analogWrite function has nothing to do with the analog pins or the analogRead function.


Syntax


analogWrite(pin, value)


Parameters


pin: the pin to write to.


value: the duty cycle: between 0 (always off) and 255 (always on).
analogReference() : Configures the reference voltage used for analog input. (default: 5V)
analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero.
analogWriteResolution() is an extension of the Analog API for the Arduino Due and Zero.

 

 

 

728x90

+ Recent posts