Skip to content

Instantly share code, notes, and snippets.

@rburnett3
Last active October 14, 2019 16:10
Show Gist options
  • Save rburnett3/f1c963c4a060733f99631f633dc61975 to your computer and use it in GitHub Desktop.
Save rburnett3/f1c963c4a060733f99631f633dc61975 to your computer and use it in GitHub Desktop.
Analog Output MaxSonar Code
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