Little Help Guys! Arduino Programming

PaulS:

To be honest, I don't fully understand what you have suggested to me(especially with timeouts and cycle stuffs) because I'm using and learning arduino for only about two weeks.

The problem that you need to solve is one of understanding whether or not the same switch is being pressed twice (2 -> 'a') quickly, or being pressed twice (2, 2). You need to also deal with other keys being pressed in the meantime. Pressing 2, 1, 2 quickly should NOT result in a, 1.

This really is not a beginner project.

There doesn't need to be a timeout. So if you wanted to type "bb" you'd press "222222" rather than "222222"

something like this:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
int incr = 0;
char btn2 = 4;


void setup()  
{
    // use the ba ud rate your bluetooth module is configured to 
    // not all baud rates are working well, i.e. ATMEGA168 works best with 57600
    Serial.begin(9600);
     Serial.println("Come at me baby!"); 
     mySerial.begin(9600);
     mySerial.println("Allright");
    // we initialize analog pin 5 as an input pin
    pinMode(sensor, INPUT);
}

void loop()
{
    
    char someChar;
    static char lastBtn = -1;
    static char lastChar = 0;
    static int numPresses = 0;
    if(digitalRead(btn2) == HIGH) {
        if (lastChar != 2) {
            if (lastChar != 0) mySerial.print(lastChar);
            numPresses = 0;
            lastBtn = 2;
        }
        someChar = '1';
        lastChar = 'a' + numPresses;
        numPresses++;
    }
    delay(100);
}