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.
Fork of SRF02v_ by
main.cpp
- Committer:
- somethingname
- Date:
- 2015-12-09
- Revision:
- 4:3f31934daa52
File content as of revision 4:3f31934daa52:
#include "mbed.h" #include "SRF02.h" #include "USBSerial.h" SRF02 sensor(p28,p27); Serial _serial_(USBTX, USBRX); // tx, rx USBSerial serial; DigitalIn sw8(p8); int main() { bool onoff=false; sw8.mode(PullUp); //serial.baud(9600); while(1) { if(onoff){ // read sensor distance in cm and print over serial port int distance = sensor.getDistanceCm(); serial.printf("Distance = %d cm\n",distance); _serial_.printf("Distance = %d cm\n",distance); // short delay before next measurement if(!sw8){onoff=false;} wait(0.060); }else{ if(!sw8){onoff=true;} } wait(0.005); } /*return 0;*/ }