Pages: [1]   Go Down
Author Topic: avr to lcd  (Read 995 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



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:

    1) 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:

Code:

#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 (22.97 KB - downloaded 6 times.)
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7176
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Because you are using pins 0 and 1 for your keypad, you can't upload your program. Pin 0 and 1 are reserved for uploading program via serial so don't use them for your keypad. If you bought your ruggeduino from rugged circuits, you may have noticed the phi-panel lcd backpacks. If you use them, you will not need to use 14 pins, but 2 pins instead, and no libraries needed for both lcd and the keypad.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are right. I thought I had got the lcd to work with 3,2,1,0 combination and that's why i hooked up the keypad to the row pins to this combo. Turns out when i checked the Lcd this morining with these nos., got gibberish.
I'm very interested in what you're doing, and in particular 2 pins, 1 for lcd and the other for the keypad?! That's awesome! Thing is I'm on an extremely tight budget and had already purchased 2 keypads, 2 2560's,a 20x4 and 16x2 sainsmart lcds (these had issues), with the ruggeduino, had a vfd to originally hook up to the MCU that bombed out and refused to work ( will check that out after the class project is done), and have my final project to turn in on the 10th. Was hoping to work with what I got without having to purchase anything else. Got a 16 x2 lcd from the lab. I like the ruggeduino for it's protective features, but im thinking may have to use one of the 2560's. I admire the work you're doing though.
What's your advice here.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7176
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you used any analog pins? Those can be used as digitql pins aw well, in case you didn't already know. Analog 0 is digital 14, etc.
Logged


Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 53
Posts: 1837
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you used any analog pins? Those can be used as digitql pins aw well, in case you didn't already know. Analog 0 is digital 14, etc.
If you are using analog pins, it is best to use the A0..A<n> names that are provided by the IDE since different boards start the analog pins at different pin numbers (i.e. UNO is 14, Leonardo is 18, etc.).

Also, some of the analog pins cannot be used as output pins, but they can be used as digital inputs IIRC.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7176
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm very interested in what you're doing, and in particular 2 pins, 1 for lcd and the other for the keypad?! That's awesome!

Yes, the lcd backpack has an ATMEGA328 on it that controls the LCD and senses the keypad so your arduino is free to do other stuff and only needs 2 pins to talk to the ATMEGA328 on the backpack using serial.read() and serial.write() or print(). The backpack's ATMEGA328 has about 3,000 lines of code so it is quite intelligent and can do lots of things such as rendering menus and multi-tap inputs and more.
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7176
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you used any analog pins? Those can be used as digitql pins aw well, in case you didn't already know. Analog 0 is digital 14, etc.
If you are using analog pins, it is best to use the A0..A<n> names that are provided by the IDE since different boards start the analog pins at different pin numbers (i.e. UNO is 14, Leonardo is 18, etc.).

Also, some of the analog pins cannot be used as output pins, but they can be used as digital inputs IIRC.

Absolutely.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good news! Not only did analog14 work for row 2 pin of the keypad but analog 15 worked for row3 pin as well.  I'm not all that hot with programming but having had a not-so-good experience in my microprocessors class, have suddenly had a renewed passion for it through the use of the arduino mcu. As you may have noticed, the overall sketch that i've sent is actually a combination of the keypad sketch and the lcd sketch and with 'logical' additions of other 'C' syntax which i figure will give me what I want.
Having made the changes above in the overall sketch, it still hangs up on the upload.
I'm thinking maybe the encoding is too long. Is there a more efficient way I can obtain the parameters in the sketch to be displayed, and am wondering where i'm going wrong.


* 1205120842.jpg (113.67 KB, 1280x960 - viewed 12 times.)

* 1205120834.jpg (59.63 KB, 1280x960 - viewed 12 times.)

* 1205120851.jpg (95.22 KB, 1280x960 - viewed 11 times.)

* 1205120920.jpg (87.39 KB, 1280x960 - viewed 14 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Although things look a bit unkempt, this is just for testing purposes. Once I get everything to work as desired then will wire everything neatly and compact into the encasing for the handheld which will hold the mcu, display and keyboard.
Here is also the vfd which I really wanted to work, but figure that the controller chip is faulty, although physical testing shows the following.


* 1126120322.jpg (73.58 KB, 1280x960 - viewed 14 times.)

* 1127121605.jpg (84.75 KB, 1280x960 - viewed 10 times.)

* 1127121606a.jpg (81.33 KB, 1280x960 - viewed 7 times.)

* 1205120842.jpg (113.67 KB, 1280x960 - viewed 18 times.)
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7176
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I still see pins 0 and 1 with wires on them. Can you remove those wires?
Logged


Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4261
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Here is also the vfd which I really wanted to work, but figure that the controller chip is faulty, although physical testing shows the following.

That makes this the third thread for this topic going back nearly 7 months.

     http://arduino.cc/forum/index.php/topic,134470.html

     http://arduino.cc/forum/index.php/topic,106553.html

“There’s never enough time to do it right, but there is always enough time to do it again”

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The lines from digital pins 0 and 1 have been removed and are in A15 and A14 respectively.
Hi Don. Still at it. Will get it to work with the lcd at least.
Logged

Pages: [1]   Go Up
Jump to: