test 1
Dependencies: BMI160 max32630fthr Adafruit_FeatherOLED USBDevice
Fork of DisplayBMI160_Oled by
Revision 12:d92a5d1d869f, committed 2020-06-14
- Comitter:
- walterluu
- Date:
- Sun Jun 14 21:20:03 2020 +0000
- Parent:
- 11:6fdec00dbb90
- Commit message:
- test 1;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Jun 14 20:17:43 2020 +0000 +++ b/main.cpp Sun Jun 14 21:20:03 2020 +0000 @@ -70,6 +70,7 @@ Timer t; +Timer sense_t; //***************************************************************************** @@ -252,21 +253,29 @@ int high =1; int low =0; DigitalOut trigger (P5_2); - trigger = high; + trigger = 1; wait_us(10); - trigger = low; + trigger = 0; - DigitalIn echo (P5_1); - if ( echo == high ) - { - - gLED = LED_ON; - wait(5); gLED = LED_OFF; - } + DigitalIn echo(P5_1); + + printf("Starting ultrasensor:"); - + while(echo == 1) // edge signal = 1 + { + sense_t.start(); + gLED = LED_ON; + if(echo == 0) { + break; + } + + } + sense_t.stop(); + gLED = LED_OFF; + printf("Ultrasensor sensor duration %f seconds\n", sense_t.read()); + //if (echo == 1) //{ // DigitalOut gLED(LED2, LED_ON); @@ -275,13 +284,13 @@ // } //*************************testing timeer ******************************************* - /* + t.start(); printf("Hello World!\n"); t.stop(); printf("The time taken was %f seconds\n", t.read()); - */ + // **********************************************************************************