forked from monkeylover1234/mesacmsrobotics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemo4.ino
92 lines (76 loc) · 2.32 KB
/
Demo4.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <avr/wdt.h>
#include "DeviceDriverSet_xxx0.h"
#include "ApplicationFunctionSet_xxx0.cpp"
// Compiler was yelling at me for some reason so I decided to put the function here.
// It should be in DeviceDriverSet_xxx0.cpp though as a part of the DeviceDriverSet_Motor class though.
// Please clean my code if you can.
int straight(ConquerorCarMotionControl direction, int distance /*In centimeters */) {
int cmPerSecond = 79; // Calibrate based on surface
float msecondsToTravel = distance/cmPerSecond * 1000;
int millisecondsToTravel = round(msecondsToTravel);
ApplicationFunctionSet_ConquerorCarMotionControl(direction, 250 );
delay(millisecondsToTravel);
ApplicationFunctionSet_ConquerorCarMotionControl(stop_it, 250 );
return 0;
}
DeviceDriverSet_Motor AppMotor;
Application_xxx Application_ConquerorCarxxx0;
MPU6050_getdata AppMPU6050getdata;
int time1 = 0;
int time2 = 0;
ConquerorCarMotionControl status = Forward;
void setup() {
delay(10000);
Serial.begin(9600);
AppMotor.DeviceDriverSet_Motor_Init();
AppMPU6050getdata.MPU6050_dveInit();
delay(2000);
AppMPU6050getdata.MPU6050_calibration();
delay(2000);
ApplicationFunctionSet_ConquerorCarMotionControl(status, 250 );
delay(1000);
ApplicationFunctionSet_ConquerorCarMotionControl(stop_it, 250 );
// straight(status, 122);
}
void loop() {
// ApplicationFunctionSet_ConquerorCarMotionControl(status, 250);
// time2 = millis();
// if (3000 < abs(time2 - time1))
// {
// if (status == Forward)
// {
// status = Backward;
// }
// else
// {
// status = Forward;
// }
// time1 = time2;
// }
// AppMotor.turn(90); //Turns the robot 90 degrees clockwise, relative to its starting position.
// delay(2000);
// AppMotor.turn(-90); //Turns the robot 90 degrees counterclockwise, relative to its starting position.
// delay(2000);
// AppMotor.turn(0); //Turns robot to its starting position.
// delay(2000);
// AppMotor.turn(-120);
// delay(2000);
// AppMotor.turn(120);
// delay(2000);
// AppMotor.turn(150);
// delay(2000);
// AppMotor.turn(-150);
// delay(2000);
// AppMotor.turn(-180);
// delay(2000);
// AppMotor.turn(180);
// delay(2000);
// AppMotor.turn(-270);
// delay(2000);
// AppMotor.turn(270);
// delay(2000);
// AppMotor.turn(-360);
// delay(2000);
// AppMotor.turn(360);
// delay(2000);
}