Hey Guys!
Got rid of the "low memory" problem thanks to a friend on my last question
THE PROBLEM NOW IS -> after searching for the black line The Arduino Robot struggles to move forward and the display flickers.
Never gets to the part where it saves the object
MEANT TO BE LIKE THIS -> https://www.youtube.com/watch?v=bnqDzNAU7JQ&t=584s
CODE
#include <ArduinoRobot.h> // include the robot library
#include <Wire.h>
#include <SPI.h>
void setup() {
Robot.begin();
Robot.beginTFT();
// add the instructions
Robot.text("Rescue\n\n place the robot on\n the rescue track\n pushing the\n obstacles away", 5, 5);
Robot.text("Press the middle\n button to start...", 5, 61);
Robot.waitContinue();
// start
Robot.fill(255, 255, 255);
Robot.stroke(255, 255, 255);
Robot.rect(0, 0, 128, 80); // erase the previous text
Robot.stroke(0, 0, 0);
Robot.text("Start", 5, 5);
// use this to calibrate the line following algorithm
// uncomment one or the other to see the different behaviors of the robot
// Robot.lineFollowConfig(14, 9, 50, 10);
Robot.lineFollowConfig(11, 7, 60, 5);
// run the rescue sequence
rescueSequence();
// find the track again
goToNext();
// run the rescue sequence a second time
rescueSequence();
}
void loop() {
//nothing here, the program only runs once.
}
// run the sequence
void rescueSequence() {
//set the motor board into line-follow mode
Robot.setMode(MODE_LINE_FOLLOW);
while (!Robot.isActionDone()) { // wait until it is no longer following the line
}
delay(1000);
// do the rescue operation
doRescue();
delay(1000);
}
void doRescue() {
// Reached the endline, engage the target
Robot.motorsWrite(200, 200);
delay(250);
Robot.motorsStop();
delay(1000);
// Turn the robot
Robot.turn(90);
Robot.motorsStop();
delay(1000);
// Move forward
Robot.motorsWrite(200, 200);
delay(500);
Robot.motorsStop();
delay(1000);
// move backwards, leave the target
Robot.motorsWrite(-200, -200);
delay(500);
Robot.motorsStop();
}
void goToNext() {
// Turn the robot
Robot.turn(-90);
Robot.motorsStop();
delay(1000);
}