Hello I'm working on a RC car using an arduino usb shield, ps3 controller and a simple usb bluetooth dongle. I'm trying to make the servo motor runs while pressing the "R1" key, but I don't find a confortable function that allows me to to such thing. I just got similar examples, just like this one:
if(PS3.PS3Connected || PS3.PS3NavigationConnected)
{
if(PS3.getButtonClick(TRIANGLE)==HIGH)
{
for(int pos = 0; pos < 180; pos++)
{
servo1.write(pos);
delay(5); // Give the servo time to move
}
}
else if(PS3.getButtonClick(CROSS)==HIGH)
{
for(int pos = 1800; pos >= 0; pos--)
{
servo1.write(pos);
delay(5); // Give the servo time to move
}
}
}
I guess that this function is the one that alows me to move the servo:
if(PS3.getButtonClick(R1)==HIGH)
But how can I make like if I'm holding the button, the servo will be moving and if I just left it, it will stop.
Someone please give me atleast one example of what should I do, I'm newbie on such topics and programming, any help can be really useful.
Thanks.