4180
Dependencies: X_NUCLEO_53L0A1 mbed
Fork of HelloWorld_VL53L0X_LPC1768 by
Diff: main.cpp
- Revision:
- 12:6abbf8827c8b
- Parent:
- 11:5186cc367be0
diff -r 5186cc367be0 -r 6abbf8827c8b main.cpp --- a/main.cpp Thu Sep 07 00:01:45 2017 +0000 +++ b/main.cpp Tue Oct 16 17:34:57 2018 +0000 @@ -3,6 +3,7 @@ #include <stdio.h> Serial pc(USBTX,USBRX); DigitalOut shdn(p26); +PwmOut speaker(p21); // This VL53L0X board test application performs a range measurement in polling mode // Use 3.3(Vout) for Vin, p28 for SDA, p27 for SCL, P26 for shdn on mbed LPC1768 @@ -30,10 +31,13 @@ status = board->init_board(); } //loop taking and printing distance + float freq = 0; + speaker =0.1; //volume while (1) { status = board->sensor_centre->get_distance(&distance); if (status == VL53L0X_ERROR_NONE) { - pc.printf("D=%ld mm\r\n", distance); + freq = distance * 1.2; + speaker.period(1.0/freq); // period } } }