Created
March 14, 2018 21:07
-
-
Save mikkoelo/be29ea74fab324ae901697fe2ac7eb59 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void setup() | |
{ | |
//initialize serial communications at a 9600 baud rate | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
// read and round the value from pin 0 | |
float num = analogRead(0); | |
int distance = analogRead(1); | |
int buzzer = map(distance, 0, 2013, 100, 2000); | |
num = round(num); | |
int rounded = (int) num; | |
tone(8, buzzer); | |
//send the rounded value over the serial port | |
Serial.println(rounded); | |
Serial.println(distance); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment