Sharp 2Y0A21 F 03
Sharp 2Y0A21 F 03
Distance Measuring Sensor Unit
Sharp 2Y0A21 F 03
This sensor can measure a distance from 10 to 80 cm with analog output. The range of output voltage is defined as a graph below.
Voltage output from 0.4 to 2.25 V (80 to 10 cm)
Sample Code:
void setup() { // put your setup code here, to run once: pinMode(A6, INPUT); pinMode(A7, INPUT); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: Serial.println(analogRead(A6)); delay(1); Serial.println(analogRead(A7)); delay(1000); }
Because the output of this sensor in analog output, So we can read data easily by using ADC. (analogRead() function in arduino) In this code, we read from 2 sharp sensors and print output to a serial port.
Reference: Datasheet
Comments
Post a Comment