Hi guys i have little prob. with my project. I m using hile loop to delay printin text afther a welcome screan. But something has to be wrong bcs text 'll get printed afther few sec anyway eaven tho button was nerver pressed. Any idea why s that?
Here is code:
//#include <Wire.h>
#include "mastermind.h"
#include "lcd_wrapper.h"
//int secret_code=generate_code();
void setup() {
lcd_init();
start_printin();
}
void loop() {
}
void start_printin(){
lcd_print_at(3, 0,(char*)"Welcome to");
lcd_print_at(3, 1,(char*)"MasterMind");
while (true) {// until enter is pressed welcome will stay printed
delay(100);
if (digitalRead(BTN_ENTER_PIN) == HIGH) {
break;
}
}
//delay(4000);
lcd_clear();
lcd_print_at(0, 0,(char*)"Your goal is to");
lcd_print_at(0, 1,(char*)"guess my secret");
delay(3000);
lcd_clear();
lcd_print_at(2, 0,(char*)"combination");
//lcd_print_at(2, 1,(char*)"combination.");
}
Is BTN_ENTER_PIN your own invention, or is it supported by the library/ies ?
It could be you are missing a pullup/pulldown resistor, depending on how you wired the button.
6v6gt:
Is BTN_ENTER_PIN your own invention, or is it supported by the library/ies ?
It could be you are missing a pullup/pulldown resistor, depending on how you wired the button.
it's practicly "my invention" but it should work bcs my friend is using same .h and .cpp files as i do and its working properly and only diference is that he is using that while elsewhere.
and its wired properly too bcs buttons worked when i tested tham sepretly. so idk why this loop is ...
The reason I asked if it was supported by the library was that (a) the library designer would have specified how the button should be wired and (b) used the appropriate pinMode() statement for it in the library.
You are missing a pinMode() statement i your code and you have not said what pullup/pulldown resistors you are using (if any).
Usually, a button is wired on the low side and the pin's built in pullup resistor is used. The effect that you have described is that of a floating input pin.