Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

OpenAccess Keypad functions

OpenAccess Keypad functions

char keypad_matrix()

{
//Serial.println(“keypad_matrix”);
if(Serial3.available())
{
char result = Serial3.read();//Read key press
return result;
}
else
{
return ‘ ‘;//equivalent to -1, a null result
}
//delay(10);
}

This code polls for keypresses.  If it returns anything then the keypresses are acted on.  Stuff like this is why it is so important to keep the code looping and not blocking.  If there are multiple keypresses buffered this will grab one and leave the rest for next loop.

void enter_pin(char c)
{
//Serial.print(“Pin Button = “);
//Serial.println(reader2);
LCD_disp(“*”);
pin[digit] = c – ‘0’;//stores as numbers rather than characters
digit++;
}

Here is how a pin is incremented, it is one of the few places I do not overwrite the entire LCD line at once.

void backspace_pin()
{
pin[digit] = 15;
//Serial.println(“backspace”);
LCD_displn(” “,1);
LCD_displn(“Pin:”,1);
if(digit >0)
{
digit–;
pin[digit] = 15;
}
for (int i = 0;i<digit;i++)//repopulates asterisks
{
LCD_disp(“*”);
}
//for(int i=0;i<(sizeof(pin)/sizeof(pin[0]));i++)
//{
// Serial.print(pin[i]);
//}
}

Removing a digit is tricky, I have to set it to an impossible to type character and rewrite the line of asterisks because I don’t support arbitrary cursor positioning.

 

void clear_pin()
{
digit = 0;
for(int i=0;i<(sizeof(pin)/sizeof(pin[0]));i++)
{
pin[i] = 15;
}
}

Clearing a pin is easy, set back to unprintable.  These steps are done in the key taking process which is longer and in the main logic code.  This is part of the greater OpenAccess project.

Read more Here







Related Pins

Review of NeoDen 4 pick and place machine with vision system
Review of NeoDen 4 pick and place machine with vision system
Solar LED Light ,20000mah  Li-ion battery , 24V solar panel with MPPT charge Controller
Solar LED Light ,20000mah Li-ion battery , 24V solar panel with MPPT charge Controller
Transfer of TI’s Wi-Fi® Alliance (WFA) Certifications to SimpleLink™ Wi-Fi CC3x00
Transfer of TI’s Wi-Fi® Alliance (WFA) Certifications to SimpleLink™ Wi-Fi CC3x00
DIY USB 5V Solar Power Pack
DIY USB 5V Solar Power Pack
Tutorial: DHT22 sensor with a PICmicro
Tutorial: DHT22 sensor with a PICmicro
BQ24650 Based MPPT li-ion Battery Chage Controller With Software MPPT adjust and 3 Channel LED P ...
BQ24650 Based MPPT li-ion Battery Chage Controller With Software MPPT adjust and 3 Channel LED PWM dimming.
Play beautiful music on an Arduino thumb piano
Play beautiful music on an Arduino thumb piano
Kids can build these circuits
Kids can build these circuits
40 dB attenuator
40 dB attenuator
A multimeter heads-up display with Arduino glasses
A multimeter heads-up display with Arduino glasses
Robotic fish swims under Arduino control
Robotic fish swims under Arduino control
Arduino Xylophone
Arduino Xylophone
MPPT Solar Charger Testing
MPPT Solar Charger Testing
Design and Application Guide of Bootstrap Circuit for High-Voltage Gate-Drive IC
Design and Application Guide of Bootstrap Circuit for High-Voltage Gate-Drive IC
ESLOV is the amazing new IoT invention kit from Arduino
ESLOV is the amazing new IoT invention kit from Arduino
μPC1237 based 2 channel speaker protector
μPC1237 based 2 channel speaker protector
ESP8266 WeatherStation Color
ESP8266 WeatherStation Color
Keyless piano project using Arduino uno
Keyless piano project using Arduino uno
IoT Wardrobe
IoT Wardrobe
Automotive CAN Transceivers
Automotive CAN Transceivers

Top


Shares