I'm trying to get a 4x4 matrix keypad to write characters to a 16x2 LCD, using a Ruggeduino. I have a program which utilizes the arduino keypad and lcd libraries, which compiles but, when attempting to upload, 'hangs up', is not uploaded, and produces the following error messages:
- avrdude: stk500v2_ReceiveMessage(): timeout, repeated about 50 times before...
...2) avrdude: stk500v2_command(): failed miserably to execute command 0x10...
...3) avrdude: initialization failed, rc=-1....(1) repeated again many times before...
...4) avrdude: stk500v2_command(): failed miserably to execute command 0x11...
...5) avrdude: stk500v2_disable(): failed to leave programming mode
The source code is as follows:
#include <LiquidCrystal.h>
#include <Keypad.h>
//lcd(RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int numRows = 2;
int numCols = 19;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'A','1','2','3'},
{'B','4','5','6'},
{'C','7','8','9'},
{'D','*','0','#'}
};
byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {3, 2, 1, 0}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600); // baud rate
lcd.begin(numRows, numCols);
lcd.clear(); // clears the display
lcd.setCursor(0,1);// sets cursor position to 1column, 2nd row
}
void loop()
{
if (Serial.available() > 0)
{
// declares keytype, gets character key
// and serial reads pressed key at Arduino Pins
char customKey = (customKeypad.getKey() && Serial.read());
// declares keytype for the digits on the keypad
// and serial reads pressed key at Arduino Pins
int digits = (customKeypad.getKey() && Serial.read());
if (customKey =='C')//keytype for Clearing display
{
lcd.clear();
}
else if (customKey == ('# && 1'))//for displaying Altitude
{
lcd.print(("Alt.=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Altitude to 1st row
lcd.print(("Alt.=")&& (digits));
}
}
else if (customKey == ('# && 2'))//for displaying Altitude Rate
{
lcd.print(("Alt.Rt.=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Altitude Rate to 1st row
lcd.print(("Alt.Rt.=")&& (digits));
}
}
else if (customKey == ('# && 3'))//for displaying Altitude Rate Limit
{
lcd.print(("AR.Lim.=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Altitude Rate Limit to 1st row
lcd.print(("AR.Lim.=")&& (digits));
}
}
else if (customKey == ('# && 4'))//for displaying Airspeed data
{
lcd.print(("AirSpd.=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Airspeed data to 1st row
lcd.print(("AirSpd.=")&& (digits));
}
}
else if (customKey == ('# && 5'))//for displaying Airspeed Rate
{
lcd.print(("A/S Rt.=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Airspeed Rate to 1st row
lcd.print(("A/S Rt.=")&& (digits));
}
}
else if (customKey == ('# && 6'))//for displaying Airspeed Rate Limit
{
lcd.print(("A/S RLim=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Airspeed Rate Limit to 1st row
lcd.print(("A/S RLim.=")&& (digits));
}
}
else if (customKey == ('# && 7'))//for displaying Pitot Pressure
{
lcd.print(("Pt/inHg=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Pitot Pressure to 1st row
lcd.print(("Pt/inHg=")&& (digits));
}
}
else if (customKey == ('# && 8'))//for displaying Static Pressure
{
lcd.print(("Ps/inHg=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Static Pressure to 1st row
lcd.print(("Ps/inHg=")&& (digits));
}
}
else if (customKey == ('# && 9'))//for displaying Engine Pressure Ratio (EPR=Pt/Ps)
{
lcd.print(("Pt/Ps=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends EPR to 1st row
lcd.print(("Pt/Ps=")&& (digits));
}
}
else if (customKey == ('# && 0'))//for displaying Mach Number
{
lcd.print(("Mach.=")&& (digits));
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Mach Number to 1st row
lcd.print(("Mach.=")&& (digits));
}
}
else if (customKey == ('B'))//for indicating unit is to be Reset and Vented
{
lcd.print("Reset & Vent");
if (customKey == ('*'))
{
lcd.clear();
lcd.setCursor(0,0);// sends Reset & Vent information to 1st row
lcd.print("Reset & Vent");
}
}
}
}
PIN CONNECTIONS:
As shown in attached doc.
pin connections.docx (23 KB)