A
Dependencies: mbed Servo SRF02
Revision 0:79e503305664, committed 2021-12-14
- Comitter:
- kosukesuzuki
- Date:
- Tue Dec 14 10:58:05 2021 +0000
- Commit message:
- A
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SRF02.lib Tue Dec 14 10:58:05 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/eencae/code/SRF02/#cb489f486ece
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Tue Dec 14 10:58:05 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 14 10:58:05 2021 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" +#include "SRF02.h" +#include "Servo.h" + +SRF02 sensor(p9,p10,0xE0); +Servo myservo(p21); +Serial pc(USBTX,USBRX,9600); + +int main() { + while(1) { + int d = sensor.getDistanceCm(); + pc.printf("Distance = %d cm\r\n",d); + + if(d <= 30){ + pc.printf("motor"); + for(int m =0; m <100; m++) { + myservo = m/100.0; + wait(0.01); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Dec 14 10:58:05 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file