Hi there!
I'm starting to use arduino and im also newbie in programming.. =(
I'm trying to make an "arduino bomb" based on a true or false game.
My goal is to attach a 16x2 display + 2 push buttons + servomotor.
Display shows the question and if the wrong choice is made, servo runs with a needle in it to blow up a baloon.
I'm having problems with the code. My buttons are not working. Can any1 help me to find any mistakes?
Thank you all!!
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int truepin = 7;
int truepinstate = LOW;
int falsepin = 8;
int falsepinstate = LOW;
void setup() {
pinMode(truepin, INPUT);
pinMode(falsepin, INPUT);
lcd.begin(16, 2);
lcd.print(" VERDADEIRO OU FALSO?");
for (int posicao = 0; posicao < 15; posicao++)
{
lcd.scrollDisplayLeft();
delay(400);
}
delay(2000);
}
void loop() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pergunta 1");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" O numero atomico do hidrogenio e 2?");
for (int posicao = 0; posicao < 23; posicao++)
{
lcd.scrollDisplayLeft();
delay(400);
}
truepinstate = digitalRead(truepin);
falsepinstate = digitalRead(falsepin);
if (truepinstate == HIGH && falsepinstate == LOW)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Muito bem!");
//servomotoraction
}
else if (truepinstate == LOW && falsepinstate == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Errou!");
//servomotoraction
}
delay(3000);
lcd.clear();