Good morning all,
I am hoping for a bit of help.
The project I am working on has several different purposes but to give you an overview. An "Observer" is on a "Section", as a competitor goes through that "Section" he or she types the competitor number on a keypad, hits enter, then on the next page that appears they type the score the competitor gets, hits enter and the loop repeats. As I progress I am going to be looking for those scores to then be saved to a CSV file on a memory card reader but that is further down the line.
Before it gets to the part I have described above there are a few other questions, "How many sections?" being one of them. Again I would like the "Observer" to be able to type in a number on the keypad and hit enter when the next screen will appear.
I have wired up the keypad through resistors so that it goes to one analogue pin. However, I am struggling with the code to actually get a number on number on the screen.
So at the moment I am asking for help with the following bit of code. I know this isn't correct but I haven't been able to find a good tutorial online with an OLEM screen.
void setupLoop ()
{
while (digitalRead(buttonEnter) == LOW)
{
lcd.setCursor(0, 0);
lcd.print("How Many");
lcd.setCursor(0, 1);
lcd.print("Sections?");
Getkey();
{
lcd.clear();
lcd.home();
lcd.print(Getkey);
lcd.setCursor(10, 1);
delay (2000);
}
delay(3000);
lcd.clear();
}
The goal is it comes onto a screen which says "How Many Sections?" the user can type on the keyad, "12", for example, then hit enter and the program will move to the next part.
This is the entirety of the code as there are probably some mistakes in the set-up.
#include <Adafruit_CharacterOLED.h>
Adafruit_CharacterOLED lcd(OLED_V2, 6, 7, 8, 9, 10, 11, 12);
//---------------------------------------
#include <OnewireKeypad.h>
#include <Wire.h>
#define Rows 4
#define Cols 3
#define Pin A0
#define Row_Res 4700
#define Col_Res 1000
char KEYS[] = {
'1', '2', '3',
'4', '5', '6',
'7', '8', '9',
'*', '0', '#'
};
OnewireKeypad <Adafruit_CharacterOLED, 12> KeyPad(lcd, KEYS, Rows, Cols, Pin, Row_Res, Col_Res );
OnewireKeypad <Print, 12> KeyPad(Serial, KEYS, Rows, Cols, Pin, Row_Res, Col_Res );
//----------------------------------------
const int buttonEnter = 4;
void setup()
{
pinMode (buttonEnter, INPUT);
//--------------------------------------
lcd.begin(16, 2);
lcd.setCursor(3, 0);
lcd.print("Welcome to");
lcd.setCursor(4, 1);
lcd.print("MiScore!");
delay(3000);
lcd.clear();
//--------------------------------------
while (digitalRead(buttonEnter) == LOW)
{
lcd.setCursor(1, 0);
lcd.print("Press Enter to");
lcd.setCursor(5, 1);
lcd.print("Begin!");
}
lcd.clear();
}
void loop()
{
setupLoop ();
mainLoop();
subLoop ();
}
void setupLoop ()
{
while (digitalRead(buttonEnter) == LOW)
{
lcd.setCursor(0, 0);
lcd.print("How Many");
lcd.setCursor(0, 1);
lcd.print("Sections?");
Getkey();
{
lcd.clear();
lcd.home();
lcd.print(Getkey);
lcd.setCursor(10, 1);
delay (2000);
}
delay(3000);
lcd.clear();
}
//---------------------------------------
lcd.setCursor(0, 0);
lcd.print("How Many");
lcd.setCursor(0, 1);
lcd.print("Laps?");
delay(3000);
lcd.clear();
//---------------------------------------
}
void mainLoop ()
{
//---------------------------------------
lcd.setCursor(0, 0);
lcd.print("Enter Section");
lcd.setCursor(0, 1);
lcd.print("Number:");
delay(3000);
lcd.clear();
//---------------------------------------
lcd.setCursor(0, 0);
lcd.print("Observers Name?");
delay(3000);
lcd.clear();
//---------------------------------------
}
void subLoop ()
{
//---------------------------------------
lcd.setCursor(0, 0);
lcd.print("Rider Number?");
delay(3000);
lcd.clear();
//---------------------------------------
lcd.setCursor(0, 0);
lcd.print("Rider Score?");
delay(3000);
lcd.clear();
//---------------------------------------
}
Any help or advice would be appreciated.
Many thanks.