Pages: [1]   Go Down
Author Topic: Flushing Arduino  (Read 1746 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Plz someone tell me how to flush Arduino...???
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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... smiley-sad
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how to clear previous programme in arduino..
Just write a new one over it.
Logged

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

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Offline Offline
Edison Member
*
Karma: 33
Posts: 1481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This isn't your problem,
Code:
 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.
« Last Edit: October 05, 2012, 12:57:23 pm by AWOL » Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5757
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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... smiley-sad

What you say simply isn't possible. Every time you upload a program it erases the previous one.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Saskatchewan
Offline Offline
Sr. Member
****
Karma: 19
Posts: 364
When the going gets weird, the weird turn pro. - Hunter S. Thompson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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

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

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 48
Posts: 2935
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19363
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

  }
 

Could certainly be simplified to:

Code:
// blah


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

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

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: