/*********************************************** LOOP *********************************************************/
void loop()
{
// *************** EASY BUTTON PRESSED **************
if (digitalRead(easy_button) == HIGH) // If the easy button is being pressed
{
if (tag_first == true) // If this is the first time we are going through this loop after the tag button has been pressed
{
if (tagged == false) // If we were previously untagged
{
//****** DO SOMETHING ONCE WHEN TAGGED
digitalWrite(red_LED, HIGH); // turn red LED --> OFF
digitalWrite(green_LED, LOW); // turn green LED --> ON
tagged = true; // We are now tagged
Serial1.print(char(tagged)); // Send to remote: true is Tagged, false is Untagged
md.setM1Speed(0);
md.setM2Speed(0);
}
else //(tagged == true) If we were previously tagged
{
//******* DO SOMETHING ONCE WHEN UNTAGGED
digitalWrite(red_LED, LOW); // turn red LED --> ON
digitalWrite(green_LED, HIGH); // turn green LED --> OFF
tagged = false; // We are now untagged
Serial1.print(char(tagged)); // Send to remote: true is Tagged, false is Untagged
}
tag_first = false;
}
if (tag_first == false)
{
if (tagged == true) // If we are tagged, do stuff constantly
{
//********** DO STUFF CONSTANTLY WHEN TAGGED
Serial1.print(char(tagged)); // Send to remote: true is Tagged, false is Untagged
}
else //(tagged == false) If we are not tagged, do things constantly
{
//*********** DO STUFF CONSTANTLY WHEN NOT TAGGED
read_joystick();
}
}
}
// *************** EASY BUTTON NOT PRESSED **************
if (digitalRead(easy_button) == LOW) // If the easy button is not being pressed
{
tag_first = true;
if (tagged == true) //If we are tagged, do things constantly
{
//DO STUFF CONSTANTLY WHEN TAGGED
}
else //(tagged == false) If we are not tagged, do things constantly
{
lcd.clear();
lcd.home();
lcd.print(joystick_x);
read_joystick();
} // end else (tagged = false)
} // end if (if easy_button == LOW)
} // end void loop()
/**************************************************** END LOOP *******************************************************/