Button and counter

hurray, I've got the code for the buttons working, or at least not crashing. Progress I guess

Now, how do I store the data in the EEPROM? and where does the Serial.Print(Good/Bad Mood); go? It doesn't seem to fit anywhere at the moment?

Many thanks

const int GOOD = 2;     // the number of the pushbutton pin
const int BAD = 9;     // the number of the pushbutton pin

//pins...
#define GOOD    3
#define BAD       4
#define RESET_COUNTS    5
#define TUNE     6 

unsigned long BadMood;
unsigned long GoodMood; 


void playTune()    
{
  digitalWrite(TUNE, HIGH);  // note this doesn't actually play a tune by itself
  delay (250);// wait a quarter of a second...or whatever you want
  digitalWrite(TUNE, LOW); 
}

void setup ()
{

pinMode(INPUT, RESET_COUNTS);
pinMode(INPUT, GOOD);
pinMode(INPUT, BAD);
pinMode(OUTPUT, TUNE);

Serial.begin(19200); 

getValuesFromEEPROM(); 
Serial.print(BadMood);
Serial.print(GoodMood);


if (RESET_COUNTS == LOW) {
    GoodMood = 0; 
    BadMood = 0; 
    storeValuesToEEPROM();

}


}

void loop ()      { 

if (digitalRead(GOOD) == LOW)    {
    while (digitalRead(GOOD) == LOW); //we don't want to keep on counting, do we???
    GoodMood++;
    //playTune();
    }

if (digitalRead(BAD) == LOW)    {
    while (digitalRead(BAD) == LOW); //we don't want to keep on counting, do we???
    BadMood++;
    //playTune();

    }

}
pinMode(INPUT, RESET_COUNTS);

Please tell me you've fixed this by now.

ha, yes I had actually, I pasted it from the old window sorry! :-/

const int GOOD = 2;     // the number of the pushbutton pin
const int BAD = 9;     // the number of the pushbutton pin

//pins...
#define GOOD    3
#define BAD       4
#define RESET_COUNTS    5
#define TUNE     6 

unsigned long BadMood;
unsigned long GoodMood; 


void playTune()    
{
  digitalWrite(TUNE, HIGH);  // note this doesn't actually play a tune by itself
  delay (250);// wait a quarter of a second...or whatever you want
  digitalWrite(TUNE, LOW); 
}

void setup ()
{

pinMode(RESET_COUNTS, INPUT);
pinMode(GOOD, INPUT);
pinMode(BAD, INPUT);
pinMode(TUNE, OUTPUT);

Serial.begin(19200); 

//getValuesFromEEPROM(); 
Serial.print(BadMood);
Serial.print(GoodMood);


if (RESET_COUNTS == LOW) {
    GoodMood = 0; 
    BadMood = 0; 
    //storeValuesToEEPROM();

}


}

void loop ()      { 

if (digitalRead(GOOD) == LOW)    {
    while (digitalRead(GOOD) == LOW); //we don't want to keep on counting, do we???
    GoodMood++;
    //playTune();
    }

if (digitalRead(BAD) == LOW)    {
    while (digitalRead(BAD) == LOW); //we don't want to keep on counting, do we???
    BadMood++;
    //playTune();

    }

}

where does the Serial.Print(Good/Bad Mood); go?

Any time you change or read one of the counts.

http://www.arduino.cc/playground/Code/EEPROMWriteAnything

void loop ()      { 

if (digitalRead(GOOD) == LOW)    {
    while (digitalRead(GOOD) == LOW); //we don't want to keep on counting, do we???
    GoodMood++;
    //playTune();
    Serial.print("Good Mood ");
    Serial.print(GoodMood);
    }

if (digitalRead(BAD) == LOW)    {
    while (digitalRead(BAD) == LOW); //we don't want to keep on counting, do we???
    BadMood++;
    //playTune();
    Serial.print("Bad Mood ");
    Serial.print(BadMood);

    }

}

Thank you very much, will have a play with it

So, the code seems fine, I've uploaded it to my arduino and nothing. Is the data is supposed to go in the serial monitor?

const int GOOD = 2;     // the number of the pushbutton pin
const int BAD = 9;     // the number of the pushbutton pin

//pins...
#define GOOD    3
#define BAD       4
#define RESET_COUNTS    5
#define TUNE     6 

unsigned long BadMood;
unsigned long GoodMood; 


void playTune()    
{
  digitalWrite(TUNE, HIGH);  // note this doesn't actually play a tune by itself
  delay (250);// wait a quarter of a second...or whatever you want
  digitalWrite(TUNE, LOW); 
}

void setup ()
{

pinMode(INPUT, RESET_COUNTS);
pinMode(INPUT, GOOD);
pinMode(INPUT, BAD);
pinMode(OUTPUT, TUNE);

Serial.begin(19200); 

//getValuesFromEEPROM(); 
Serial.print(BadMood);
Serial.print(GoodMood);

if (RESET_COUNTS == LOW) {
    GoodMood = 0; 
    BadMood = 0; 
    //storeValuesToEEPROM();
}
}


void loop ()      { 

if (digitalRead(GOOD) == LOW)    {
    while (digitalRead(GOOD) == LOW); //we don't want to keep on counting, do we???
    GoodMood++;
    playTune();
    Serial.print("Good Mood ");
    Serial.print(GoodMood);
    }

if (digitalRead(BAD) == LOW)    {
    while (digitalRead(BAD) == LOW); //we don't want to keep on counting, do we???
    BadMood++;
    playTune();
    Serial.print("Bad Mood ");
    Serial.print(BadMood);

    }
}

I have tried the code with this set-up, it might be wrong?

Basically, it the problem hardware or software?

Sorry to be so clueless.

Have you got the serial monitor open? (it is the icon to the right of the code upload icon) Have you got the serial line bit rate set to 19200?

yes I have, it doesn’t do anything. ?it just shows ‘À0’. If it was working properly, it would do something when I press the button right?

I suspect my set-up might be wrong?

http://imageshack.us/photo/my-images/69/photo3xp.jpg/

t just shows 'À0'

Are you sure the speed is set correctly? Try adding a "Serial.print ("The quick brown fox");" immediately after the "Serial.begin" in "setup"

it displays 'P¡?quick brown fox00'

the serial monitor is on 'no line ending'l, '19200 baud'

OK, so the serial line is working, and your initial totals are working. So, why aren't your switches working? How are they wired?

this is the set-up i used. The two buttons are connected to pin 2 and 9.

I am missing a trick? I’ve used the same set-upo from a tutorials, which worked before.

http://img684.imageshack.us/img684/5869/photo5oq.jpg

Time to add in some debug prints. Start with the initial state of the button inputs.

It isn't important right now, but if we take this if (RESET_COUNTS == LOW) { section of your last posted code, and apply what the preprocessor does to it, we get to see what the C compiler sees:if (5 == 0) {. That's pretty unlikely, don't you think?

Can you post your current code with debug prints and output, please?

ok, I'm just discovering what debugging means, and I thought it was almost done!

Will look into it and probably post back on Monday.

Thanks again for your assistance.