Hello Again Guys,
I am pretty rusty at my programming language and am trying to get by using the example codes. My goal is to utilize my rfid input signal to rotate a motor one way, and once the motor is completed it's rotation it stops and waits for another rfid signal to rotate the opposite direction. The problem that I'm having is that it skips straight to the reverse mode and does not go back to the forward direction. Can anyone help debug this flaw in programming?
// Library importation needs to take place to use functions
#include "mbed.h"
#include "Motor.h"
#include "ID12RFID.h"
Motor dcMotor(p23, p11, p12);
ID12RFID rfid(p14);
Serial pc(USBTX, USBRX);
// Declare output pins for test
DigitalOut myled(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
DigitalOut myled4(LED4);
// Main Program Syntax
int main() {
myled = 0;
while (1) {
// locking mode
if (myled = 0 && (rfid.readable())){
pc.printf("RFID Tag number : %d\n", rfid.read());
// Go from full speed forward, to full speed reverse
for (float speed=0.4; speed > -1.0 ; speed -= 0.1) {
dcMotor.speed(speed);
// state 2 in forward
myled2 = 1;
pc.printf("I'm in Forward");
wait(0.05);
}
myled = myled + 1;
}
// unlocking mode
else if (myled = 1 && (rfid.readable())){
pc.printf("RFID Tag number : %d\n", rfid.read());
// Go from full speed reverse, to full speed forward
for (float speed=-0.4; speed < 1.0 ; speed += 0.1) {
dcMotor.speed(speed);
// state 3 in reverse
myled3 = 1; // on
pc.printf("I'm in Reverse");
wait(0.05);
}
myled = myled - 1;
}
}
}
Hello Again Guys,
I am pretty rusty at my programming language and am trying to get by using the example codes. My goal is to utilize my rfid input signal to rotate a motor one way, and once the motor is completed it's rotation it stops and waits for another rfid signal to rotate the opposite direction. The problem that I'm having is that it skips straight to the reverse mode and does not go back to the forward direction. Can anyone help debug this flaw in programming?