Good question!
In the video I had pressed the button/kill switch to stop the robot, then after setting the robot down I pressed the reset button on the Arduino.
When you say "power toggle switch," do you mean actually remove power from the robot, or are you just wanting to be able to start and stop it?
If you want to completely cut off power to the robot, then it's going to be tricky.. You'll need a slide switch and will have to cut the GND wire on the battery pack and do some soldering. I can walk you through this if it's what you really want to do.
On the other hand, if you just want to be able to start and stop the wheels (like the current kill switch, but just with the ability to make it start again using the same button instead of pressing the reset button on the Arduino), then you can slightly modify the kill switch code.
Change this code:
if(digitalRead(2) == HIGH) // if the push button switch was pressed
{
while(1)
{
leftMotor.write(90);
rightMotor.write(90);
}
}
To this:
if(digitalRead(2) == HIGH) // if the push button switch was pressed
{
leftMotor.write(90);
rightMotor.write(90);
delay(1000); // sleep a second to give the user time to lift their finger off the button
while(1)
{
if(digitalRead(2) == HIGH) // if the push button switch was pressed
{
break; // break out of the loop to allow the program to resume execution
}
}
}
That's untested, but I think it should work.
The advantage of doing this instead of using the reset button on the Arduino (like I did in the video) is that it doesn't restart the program -- it actually continues execution from where it left off. I think I'll change the tutorial to incorporate this after I get a chance to test it out.