Hey everyone, here's the issue I'm having:
I've attempted to setup an interrupt that is able to determine which external switch has been hit, then respond accordingly. I'm relatively new to this, so bear with me.
Here's the current code:
#include <SOSS.h>
#include <AIT.h>
void setup()
{
configArduino ();
void motor1 ();
void motor2 ();
attachInterrupt (0, rightInterrupt, LOW); //for pin D2
attachInterrupt (1, leftInterrupt, LOW); //for pin D3
}
void rightInterrupt ()
{
pause (5);
if (readInput (2) ==1 && readInput (3) ==1) return;
motor1 ('o', 0);
motor2 ('o', 0);
pause (50);
return;
if (readInput (2) ==1 || readInput (3)==0)
{
motor1 ('b', 80);
motor2 ('b', 80);
pause (500);
motor1 ('b', 80);
motor2 ('a', 80);
pause (750);
return;
}
return;
}
void leftInterrupt ()
{
pause (5);
if (readInput (2) ==1 && readInput (3) ==1) return;
motor1 ('o', 0);
motor2 ('o', 0);
pause (50);
while (readInput (2) ==0 || readInput (3)==1)
{
motor1 ('o', 0);
motor2 ('o', 0);
pause (50);
motor1 ('b', 80);
motor2 ('b', 80);
pause (500);
motor1 ('b', 80);
motor2 ('a', 80);
pause (750);
}
return;
}
void loop()
{
motor1 ('a', 40);
motor2 ('a', 40);
void leftInterrupt();
void rightInterrupt();
}
What it's supposed to do:
When a the interrupt is triggered by the external switch, I want to have the motors first shut off ('o') , then go in reverse ('b'), then turn (one motor off while the other turns).
Currently what happens is that when one of the switches is pressed, it does what Is written in the code, but it never exits the interrupt function, it just continues to perform what is in the interrupt function.
So the question is, what have I done wrong?
Thanks in advance.