Go Down

Topic: Little Help Guys! Arduino Programming (Read 1 time) previous topic - next topic

kelvinsm


Suggest you step back from the problem and describe what you're trying to achieve. On one side of your solution you have a keypad that looks like a conventional phone keypad. It looks like you want to use this like a conventional phone keypad. Ignoring for the moment the magic that has to occur to figure out what character is being generated based on key presses, what is ultimately going to happen with the result - what's it for?


I'm making a cellphone for the blind. It is a phone that has bluetooth, gps, mp3 and can receive and send text messages and calls. It should also have a voice prompt that will read text messages from the phone. And it should also have a braille keypad. It was suggested to us to make a bluetooth keypad that will serve as the main controller for the android phone for the blind. The keypad that will be using is a 3x4 keypad and the mcu we're usin is an arduino clone atmega328.

PeterH

On my phone, when I'm using the keypad to enter text I press '2' and it shows 'a', I press '2' again and the 'a' changes to a 'b'. Press again and it changes to a 'c'. Not being familiar enough with it to compose a text without looking, I need this feedback to know what character is selected so I can keep pecking away at the keys until it shows what I want. Are you going to provide similar feedback in your system? If so, how?
I only provide help via the forum - please do not contact me for private consultancy.

kelvinsm


On my phone, when I'm using the keypad to enter text I press '2' and it shows 'a', I press '2' again and the 'a' changes to a 'b'. Press again and it changes to a 'c'. Not being familiar enough with it to compose a text without looking, I need this feedback to know what character is selected so I can keep pecking away at the keys until it shows what I want. Are you going to provide similar feedback in your system? If so, how?


yep, I think that's the best way to make a keypad, just the way you said it, "I press '2' and it shows 'a', I press '2' again and the 'a' changes to a 'b'. Press again and it changes to a 'c'.". I'm not sure how will I do it. But I'm thinking having many If statements.

PaulS

Quote
"I press '2' and it shows 'a', I press '2' again and the 'a' changes to a 'b'. Press again and it changes to a 'c'.". I'm not sure how will I do it. But I'm thinking having many If statements.

Keep in mind that pressing another key in between needs to reset the count of key presses. And, you need to deal, with some keys, like 3, where the user might want to produce "ee" that even the same key pressed more than once may, or may not, be trying to generate a new letter.

That is why the timing between keypresses is important.

kelvinsm


There doesn't need to be a timeout. So if you wanted to type "bb" you'd press "222<right>222" rather than "222<pause>222"

something like this:
Code: [Select]

#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);
}

[/quote]

WizenedEE, what happen is,

https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash4/314674_2587553506143_471668955_n.jpg


Go Up