Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void isrB() {
void setup() {
Serial.begin(115200);

// Set all the motor control pins to outputs
pinMode(pwmPin, OUTPUT);
pinMode(enableForwardPin, OUTPUT);
pinMode(enableBackwardPin, OUTPUT);
// Set all the motor control pins to outputs
pinMode(pwmPin, OUTPUT);
pinMode(enableForwardPin, OUTPUT);
pinMode(enableBackwardPin, OUTPUT);

pinMode(encoderPinA, INPUT_PULLUP);
pinMode(encoderPinB, INPUT_PULLUP);
Expand All @@ -53,10 +53,10 @@ void setup() {

attachInterrupt(digitalPinToInterrupt(encoderPinA), isrA, CHANGE);
attachInterrupt(digitalPinToInterrupt(encoderPinB), isrB, CHANGE);
// Turn off motors - Initial state
digitalWrite(enableForwardPin, LOW);
digitalWrite(enableBackwardPin, LOW);
// Turn off motors - Initial state
digitalWrite(enableForwardPin, LOW);
digitalWrite(enableBackwardPin, LOW);
}

void setM1MotorTarget (const unsigned int value)
Expand Down Expand Up @@ -115,25 +115,25 @@ void loop() {
if(ProtectedCount == 100)
{
digitalWrite(enableForwardPin, LOW);
digitalWrite(enableBackwardPin, LOW);
digitalWrite(enableBackwardPin, LOW);
}
else if (ProtectedCount > 100)
{
digitalWrite(enableForwardPin, LOW);
digitalWrite(enableBackwardPin, HIGH);
digitalWrite(enableBackwardPin, HIGH);
}
else if (ProtectedCount < 100)
{
digitalWrite(enableForwardPin, HIGH);
digitalWrite(enableBackwardPin, LOW);
digitalWrite(enableBackwardPin, LOW);
}

// if (readI == LOW)
// {
// digitalWrite(enableForwardPin, LOW);
// digitalWrite(enableBackwardPin, LOW);
// digitalWrite(enableBackwardPin, LOW);
// digitalWrite(led, HIGH);
// }

Serial.println(ProtectedCount);
}
}