Two button edge detection.

Hi Everyone.

I have been playing with Arduino for a year now and have been able to make a few little projects. I learned about edge detection and was able to make a rain gauge using a tip bucket and a nano with a lcd display. I want to add one more thing to it but am having trouble. For the sake of test I have a nano with 2 buttons attached. Button 1 is the set point for the amount of rain to trigger another action like fire a relay. Button 2 acts as the tip bucket rain gauge. I really don't know or may not fully understand how the code is looping. When I run the code I can click button one and make it count but once I click button 2 i am no longer able to click button 1 and make it change. Also when I click button 2 it does not count up for me. I was wondering if this is the best way to go about it or should I have 3 buttons. On detection that button one is high it would let me set the set point for the rain fall amount then use button 3 to simulate the tip bucket. Here is my code thanks so much for the help.

const int  buttonApin = 2;    
const int  buttonBpin = 3;
const int relaypin = 5;       

// Variables 
int tipbucketcount = 0;//for setting fall shutoff
int buttonAcounter = 0;// counter for the number of button presses
int buttonBcounter = 0;// counter for setting the amount of rain fall that is required to trip the well
int buttonAstate = 0;//current state of button A
int buttonBstate = 0;// current state of button B
int lastbuttonAstate = 0; //previous state of the A button
int lastbuttonBstate = 0;// previous state of the B button
float rainamount = 0;//current amount of rain collected
float shutdown = 0;  //Reading from the pot for the amount to kill motor at

void setup() {
  pinMode(buttonApin, INPUT);  // initialize the button pin as a input:
  pinMode(buttonApin, INPUT);

   //for (int i = 0; i < 255; i++)
  //  EEPROM.write(i, i);
  Serial.begin(9600);
  
   buttonBstate = digitalRead(buttonBpin);
}

void loop() {
buttonAstate = digitalRead(buttonApin);
   
if (buttonAstate != lastbuttonAstate) {  
   if (buttonAstate == HIGH) {  
       buttonAcounter++;
       }
      }
      lastbuttonAstate = buttonAstate;   
if (buttonBstate != lastbuttonBstate) {  
   if (buttonBstate == HIGH) {  
      buttonBcounter++;
      }
       lastbuttonBstate = buttonBstate;   
}
 
Serial.print(buttonAcount);
Serial.print("  -------------   ");
Serial.println(buttonBcount);
}
buttonBstate = digitalRead(buttonBpin);

This is in setup. Move it to loop.

I see no debouncing on the switches here.
Do you have pull-ups attached to the switches?

look at your variables, too...

Serial.print(buttonAcount);
Serial.print("  -------------   ");
Serial.println(buttonBcount);

you should really try to get your code to compile first.

Yes I have a resistors from ground to the pin. Then I have a switch between 5v and the pin. I really feel stupid about the two mistakes. I have been working on this at night after work and I was so frustrated that I was not able to see this straight. I do appreciate your help. The comment about I should get it to compile first was a little off. You did find the naming mistakes but I was apple to compile and upload to the nano just the way I have the code shown. I am using 1.0.5 but I made those two little changes which in turn are big mistakes now it works just like I want it to.

Thanks again.