Hi Guys ,,
I want to create a program with arduino UNO to calculate a number + number ... using :
- LCD to type "what is 1st number?" and "what is 2nd number?" ...etc.
2)button as a "next" the questions.
3)button as a "counter" .
That's My code :
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int next_but = 8;
int number_but = 9;
int i = 0;
int next_but_state;
int next_but_state2;
int next_but_state3;
int number_but_state;
int last_number_but_state;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(next_but, INPUT_PULLUP);
pinMode(number_but, INPUT_PULLUP);
lcd.print("Hello In My CLC");
}
void loop() {
// put your main code here, to run repeatedly:
next_but_state = digitalRead(next_but);
number_but_state = digitalRead(number_but);
if (next_but_state == LOW)
{
lcd.clear();
lcd.print("What is 1st No?");
next_but_state2 = digitalRead(next_but);
if (next_but_state2 == LOW)
{
lcd.clear();
lcd.print("What is 2nd No?");
next_but_state3 = digitalRead(next_but);
if (next_but_state3 == LOW)
{
lcd.clear();
lcd.print("The Result is = ");
}
}
}
if (number_but_state != last_number_but_state) {
if (number_but_state == LOW)
{
i ++;
lcd.setCursor(1, 1);
lcd.print (i);
}
}
last_number_but_state = number_but_state;
}
the order of the question..It isn't correct
