Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect X_NUCLEO_53L0A1
Diff: thisismain.cpp
- Revision:
- 4:1790aa9234a3
- Parent:
- 3:7486869c8027
- Child:
- 5:d34d14d33a89
- Child:
- 19:f76e4ffddbe1
--- a/thisismain.cpp Tue Mar 31 19:50:37 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#include "mbed.h"
-#include "XNucleo53L0A1.h"
-#include <stdio.h>
-#include "Speaker.h"
-
-Serial pc(USBTX,USBRX);
-DigitalOut shdn(p26);
-#define VL53L0_I2C_SDA p28
-#define VL53L0_I2C_SCL p27
-
-static XNucleo53L0A1 *board=NULL;
-uint32_t distance;
-
-bool state = false;
-Speaker mySpeaker(p22);
-double freq [30];
-
-double *record(double freq1[30])
-{
- double freq2;
- int status;
- uint32_t distance;
- DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
- /* creates the 53L0A1 expansion board singleton obj */
- board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2);
- shdn = 0; //must reset sensor for an mbed reset to work
- wait(0.1);
- shdn = 1;
- wait(0.1);
- /* init the 53L0A1 board with default values */
- status = board->init_board();
- while (status) {
- status = board->init_board();
- }
- for(int i = 0; i<30; i++)
- {
- status = board->sensor_centre->get_distance(&distance);
- if (status == VL53L0X_ERROR_NONE) {
- if (distance < 58){
- freq2 = 523.25;
- }
- else if(distance >= 58 && distance < 116){
- freq2 = 554.37;
- }
- else if(distance >= 116 && distance < 174){
- freq2 = 587.33;
- }
- else if(distance >= 174 && distance < 232){
- freq2 = 622.25;
- }
- else if(distance >= 232 && distance < 290){
- freq2 = 659.26;
- }
- else if(distance >= 290 && distance < 348){
- freq2 = 698.46;
- }
- else if(distance >= 348 && distance < 406){
- freq2 = 739.99;
- }
- else if(distance >= 406 && distance < 464){
- freq2 = 783.99;
- }
- else if(distance >= 464 && distance < 522){
- freq2 = 830.61;
- }
- else if(distance >= 522 && distance < 580){
- freq2 = 880.00;
- }
- else if(distance >= 580 && distance < 638){
- freq2 = 932.33;
- }
- else {
- freq2 = 987.77;
- }
- freq1[i] = freq2;
- wait (1);
- }
- }
- return freq1;
-}
-
-int main()
-{
- while (1)
- {
- if (state == false){
- record(freq);
- state = true;
- }
- if (state == true){
- for (int i = 0; i<30; i++){
- mySpeaker.PlayNote(freq[i],1.0,0.1);
- }
- state = false;
- }
- }
-}
\ No newline at end of file
