角度調整用のプログラムです。 (モータードライバー+磁気センサー)
Dependencies: ATP3012 mbed a HMC US015_2 getGPS
main.cpp
- Committer:
- ushiroji
- Date:
- 2021-12-14
- Revision:
- 2:83023bafb526
- Parent:
- 1:f70beec382b6
File content as of revision 2:83023bafb526:
#include "mbed.h" // 自作関数 #include "Function.h" int main() { double angle = 0; Move('2', 0.5); wait(20); Move('2', 0.3); wait(10); Move('2', 0.18); wait(10); Move('1', 0); wait(10); Calibration(); compass.setOpMode(HMC6352_CONTINUOUS, 1, 20); angle = compass.sample() / 10; xbee.printf("%f\r\n", angle); //角度調節 while(1) { if(angle < 20 || angle > 340) { //角度判定 xbee.printf("direction finish\n\r"); Move('1', 0); //停止 wait(5); compass.setOpMode(HMC6352_CONTINUOUS, 1, 20); angle = compass.sample() / 10; xbee.printf("%f\r\n", angle); } else { Move('4', 0.15);//時計回りに回転 compass.setOpMode(HMC6352_CONTINUOUS, 1, 20); angle = compass.sample() / 10; xbee.printf("%f\r\n", angle); speak(); } } }