Last active
March 8, 2024 05:58
-
-
Save Maxbotix/b417753919ce736d4ef31f46aa73f313 to your computer and use it in GitHub Desktop.
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
const int anPin = 0; | |
long anVolt, cm; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void read_sensor(){ | |
anVolt = analogRead(anPin); | |
cm = anVolt/2; | |
} | |
void print_range(){ | |
Serial.print(“Range = ”); | |
Serial.print(cm); | |
Serial.print(” cm “); | |
Serial.print('\n'); | |
} | |
void loop() { | |
read_sensor(); | |
print_range(); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment