Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // เคลื่อนที่ไปในทิศทางที่ต้องการด้วยเข็มทิศ หยุดการเคลื่อนที่ด้วยเวลา
- #include <ipst.h>
- void trackc_t(int c, float time) //แทร็กเข็มทิศ หยุดด้วยเวลา
- {
- float t;
- t = 0;
- compass_readConfig();
- while (1)
- {
- if (time < t)
- { break; }
- else if (compass_read() <= c + 2 && compass_read() >= c - 2)
- { fd(50); t = t + 0.1; }
- else if (compass_read() < c + 2)
- { sr(30); t = t + 0.1; }
- else if (compass_read() > c - 2)
- { sl(30); t = t + 0.1; }
- }
- }
- void left_c(int c)
- {
- compass_readConfig();
- while (compass_read() > c)
- {
- sl(40);
- }
- }
- void right(int c)
- {
- compass_readConfig();
- while (compass_read() < c)
- {
- sr(40);
- }
- }
- void setup() {
- compass_readConfig();
- compass_factoryReset();
- }
- void loop() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement