-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRobocon.ino
53 lines (42 loc) · 1004 Bytes
/
Robocon.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
#include "Sensor.h"
#include "Bot.h"
#include "Setup.h"
Bot bot;
void setup() {
//parameter is in setup header.
Initializer::initializePins();
bot.initializeBotSensor();
Serial.begin(9600);
}
void loop() {
//Serial.println(pulseIn(RIGHTSENSEIN , LOW));
//bot.testSensor();
//Serial.println(" ");
float RPM = 50, rightRPM, leftRPM;
int error = 0;
int Kp = 20;
int leftCount = 0;
int rightCount = 0;
// int direction;
while(1){
bot.testSensor();
// error = bot.getError();
// Serial.println(error);
// rightRPM = (RPM + Kp * error); leftRPM = (RPM - Kp * error);
// bot.moveForward(leftRPM,rightRPM);
// direction = bot.isDirection();
// if(direction >0){
// if(direction ==LEFT)leftCount+=1;
// if(direction ==RIGHT)rightCount+=1;
// }else {
// leftCount = 0;
// rightCount=0;
// }
// if(leftCount>=10){
// bot.moveLeft(70);
// }
// if(rightCount >=10){
// //bot.moveRight();
// }
}
}