Last active
October 14, 2019 16:10
-
-
Save rburnett3/f1c963c4a060733f99631f633dc61975 to your computer and use it in GitHub Desktop.
Analog Output MaxSonar Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print_data(); | |
delay(1000); | |
}/* Arduino example code for MaxBotix MB7389 HRXL-MaxSonar-WR weather resistant ultrasonic distance sensor: analog voltage output. More info: www.makerguides.com */ | |
#define sensorPin A0 | |
int distance = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void read_sensor() { | |
distance = analogRead(sensorPin) * 5; | |
} | |
void print_data() { | |
Serial.print("distance = "); | |
Serial.print(distance); | |
Serial.println(" mm"); | |
} | |
void loop() { | |
read_sensor(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment