Created
January 14, 2020 06:57
-
-
Save deviceplususer/64a7dd3bf2ed58c7a3a352f359fcb829 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
#include <Wire.h> | |
#include <VL6180X.h> | |
#define SPEAKER 8 | |
VL6180X sensor; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Wire.begin(); | |
sensor.init(); | |
sensor.configureDefault(); | |
sensor.setTimeout(500); | |
} | |
void loop() | |
{ | |
float value = sensor.readRangeSingleMillimeters(); | |
float adjustValue = map(value, 0, 200, 0, 1000); | |
tone(SPEAKER , adjustValue ); | |
Serial.println(value); | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment