Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created January 14, 2020 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviceplususer/64a7dd3bf2ed58c7a3a352f359fcb829 to your computer and use it in GitHub Desktop.
Save deviceplususer/64a7dd3bf2ed58c7a3a352f359fcb829 to your computer and use it in GitHub Desktop.
#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