Created
January 8, 2020 02:27
-
-
Save deviceplususer/020ce9194907af90da236e9e533265b0 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