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.
main.cpp
00001 #include "mbed.h" 00002 #include "MB1210.h" 00003 00004 DigitalOut debugled(LED1); 00005 Serial Computer(USBTX, USBRX); 00006 00007 MB1210 RangeFinder(p12, p15, p13, p14); 00008 float Range; 00009 int main() 00010 { 00011 Computer.baud(9600); 00012 debugled = 0; 00013 RangeFinder.Unit(39.370);//change units to inches 00014 RangeFinder.AttachInterruptBuffer(&Range); 00015 RangeFinder.Mode(0x0A); 00016 while(1) 00017 { 00018 debugled = !debugled; 00019 RangeFinder.RequestSyncRead();//request a range reading 00020 wait_ms(100);//wait for reading to be prepared 00021 //RangeFinder.Mode(0);//switch to PWM mode 00022 //Computer.printf("PWM reading: %f in | ", Range); 00023 //RangeFinder.Mode(1);//switch to Analog mode 00024 //Computer.printf("Analog reading: %f in | ", Range); 00025 //RangeFinder.Mode(2);//switch to serial mode 00026 Computer.printf("Serial reading: %f in | ", Range); 00027 wait(0.9); 00028 } 00029 }
Generated on Thu Jul 14 2022 10:11:24 by
1.7.2