Times work well on hardware for now. Need to connect it to projector

This commit is contained in:
Matt McWilliams 2023-02-13 20:49:49 -05:00
parent 609f604e4c
commit 724da68b0e
1 changed files with 19 additions and 11 deletions

View File

@ -22,8 +22,9 @@
#define Fbutton 3
#define Bbutton 4
const int frameTime = 40; //ms
const int frameSpeed = 255;
const int frameTime = 200; //ms
const int pullSpeed = 255;
const int pushSpeed = 125;
const int buttonPress = 100; //ms
/**
@ -138,8 +139,11 @@ void forward (int source) {
softSerial.write(Fcmd);
}
Ftime = timer;
set_speed(Fmotor, frameSpeed);
set_speed(Fmotor, pullSpeed);
set_speed(Bmotor, pushSpeed);
Frunning = true;
clockwise(Fmotor);
clockwise(Bmotor);
}
void backward (int source) {
@ -150,16 +154,21 @@ void backward (int source) {
softSerial.write(Bcmd);
}
Btime = timer;
set_speed(Bmotor, frameSpeed);
set_speed(Bmotor, pullSpeed);
set_speed(Fmotor, pushSpeed);
Brunning = true;
counter_clockwise(Bmotor);
counter_clockwise(Fmotor);
}
void monitor () {
if (Frunning && timer - Ftime >= frameTime) {
stop(Fmotor);
stop(Bmotor);
}
if (Brunning && timer - Btime >= frameTime) {
stop(Bmotor);
stop(Fmotor);
}
}
@ -176,6 +185,7 @@ void set_speed (int motor, int val){
}
}
/*
void clockwise_fade (int motor, int startSpeed, int stopSpeed, int ms) {
int steps = ceil((float) ms / (float) abs(stopSpeed - startSpeed));
int stepMs = round((float) ms / (float) steps);
@ -231,16 +241,15 @@ void counter_clockwise_fade (int motor, int startSpeed, int stopSpeed, int ms) {
Bspeed = stopSpeed;
}
}
*/
void clockwise (int motor){
if (motor == Fmotor) {
analogWrite(Fpos, Fspeed);
analogWrite(Fneg, 0);
Frunning = true;
} else if (motor == Bmotor) {
}
if (motor == Bmotor) {
analogWrite(Bpos, Bspeed);
analogWrite(Bneg, 0);
Brunning = true;
}
}
@ -248,11 +257,10 @@ void counter_clockwise (int motor){
if (motor == Fmotor) {
analogWrite(Fpos, 0);
analogWrite(Fneg, Fspeed);
Frunning = true;
} else if (motor == Bmotor) {
}
if (motor == Bmotor) {
analogWrite(Bpos, 0);
analogWrite(Bneg, Bspeed);
Brunning = true;
}
}