Go Down

Topic: Flushing Arduino (Read 1 time) previous topic - next topic

KeithRB

you can always program it with an empty setuop and loop, the "minimal" arduino program:
http://arduino.cc/en/Tutorial/BareMinimum

But as was said, it should never be necessary to "flush" your Arduino. (unless you are developing some sort of robotic sewer rat...)

Mfia

I even assumed the same n overwrited a program over it.
i am tryin to connect a PS2 wireless remote using arduino so without pressing any button i am already getting the
outputs along with the ones which i pressed.

here is my code:
#include <PS2X_lib.h>
#include <Servo.h>


PS2X ps2x;
Servo myservo;

int error=0;
int type=0;
byte vibrate=0;

int pos=90;
const byte servoPin=9;
byte incomingByte;


void setup()
{
Serial.begin(57600);
myservo.attach(9);
pinMode(servoPin,OUTPUT);

error=ps2x.config_gamepad(10,12,11,13,true,false);   //[clock,command,attention,data,pressure,rumble]

if(error==0)
{
Serial.println("PS2 CONTROLLER FOUND, CONFIGURED SUCCESSFUL");
Serial.println("TRY ALL BUTTONS,X WILL VIBRATE THE CONTROLLER");
Serial.println("not for now:HOLDING  L1 OR R1 WILL PRINT OUT THE ANALOG STICK VALUES");
Serial.println("LETS GET IT ON!!!!!");
}
else if(error==1)
Serial.println("NO CONTROLLER FOUND ,CHECK WIRING");
else if(error==2)
Serial.println("CONTROLLER FOUND BUT NOT ACCEPTING COMMANDS");
else if(error==3)
Serial.println("CONTROLLER REFUSING TO ENTER PRESSURE MODE,MAY NOT SUPPORT IT");

type=ps2x.readType();
switch(type)
{
case 0: Serial.println("UNKNOWN CONTROLLER TYPE");
break;
case 1: Serial.println("DUALSHOCK CONTROLLER FOUND");
break;
case 2: Serial.println("GUITAR HERO CONTROLLER FOUND");
break;
}
}


void loop()
{
 
 type=1;
 error=0;
if((error==1)||(error==2)||(error==3))
{
return;
}
else if(error==0)
{
if(type==1)
{
ps2x.read_gamepad();

if(ps2x.Button(PSB_GREEN))
{
Serial.println("YOU PRESSED TRIANGLE");
pos=0;
myservo.write(pos);
}
if(ps2x.Button(PSB_RED))
{
Serial.println("YOU PRESSED CIRCLE");
pos=135;
myservo.write(pos);
}
if(ps2x.Button(PSB_PINK))
{
Serial.println("YOU PRESSED SQUARE");
pos=45;
myservo.write(pos);
}

}

}
delay(20);
}

AWOL

#7
Oct 05, 2012, 07:55 pm Last Edit: Oct 05, 2012, 07:57 pm by AWOL Reason: 1
This isn't your problem,
Code: [Select]
 error=0;
if((error==1)||(error==2)||(error==3))
but why bother?

Please use code tags when posting code.
And indentation, I really like good indentation.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Mfia

Code: [Select]
type=1;
  error=0;

I included this part so that code should run...before .. code wasn't working..I dont think there is error in this part.. :smiley-slim:

fungus


how to clear previous programme in arduino.....I m programming wireless ps2 controller using arduino ...when I uploaded programme for first time I gave input through ps2 controller and I got some output...but after that I modified my programme  and uploaded it again on ps2 then it started giving previous output along with present one... :(


What you say simply isn't possible. Every time you upload a program it erases the previous one.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up