Flushing Arduino

Plz someone tell me how to flush Arduino…???

Ummm... drop it in the toilet and hit the lever?

You need to clarify what you mean by 'flush the Arduino.'

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... :(

how to clear previous programme in arduino..

Just write a new one over it.

That's either a bug in your new code, or a failure to upload the new code to the Arduino (and the IDE would have generated an error if that had occurred). The act of uploading a new program overwrites the previous program, no other steps need to be taken.

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...)

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);
}

This isn't your problem,

  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.

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.. :relaxed:

Mfia: 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.

Mfia: 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.. :relaxed:

Sure there isn't really an error there but what Awol is getting at is that assigning a variable a value then immediately testing it for different values is pointless. That you had to assign values to these to make it work suggest that they aren't getting the values you think they should when they should.

I have found that when I start having to kludge things to make a program work I've got a problem somewhere.

I have found that when I start having to kludge things to make a program work I’ve got a problem somewhere.

Some of the BEST advice ever offered. Something I had to learn the hard way… That there is only ONE successful method that is repeatable every time.
Today when I see someone’s Kludge… I have to wonder If in my wanderings if I’ve ever done anything like that… and pray it had an early and painless death.
I guess the bottom line is that your work Should be dome in such a manner that you are proud to place your name on it in a prominent place. If Not… It’s a Kludge.

Bob

  type=1;
  error=0;
  if(error==0)
  {
    if(type==1)
    {
      // blah
    }

  }

Could certainly be simplified to:

// blah

... it started giving previous output along with present one ...

Maybe your code had a bug? You could simplify it.