Help about phi_panel using analog pins.

Hi!

I’m trying to test phi_panel, but I can’t figure out where I’m wrong. My board is cheap LCD KEypad from ebay, but it is actual this shield:
http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)
According to schematic there is 5 resistors on analog pin 0.
I succesfully test that code from page, and I’m sure shield and software is ok.
Then I’m use analog template using analog keys, and change analog setings values according to already tested code above:

//int values[]={0, 144, 342, 505, 742}; //These numbers need to increase monotonically. The 342 works better on my setup but you will need to change it back.
int values[]={50, 250, 450, 650, 850}; //Cheap keypad from ebay

But I always get 00 00 from shield. Where I’m wrong ?

This is whole code :

#include <LiquidCrystal.h>
#include <Wire.h>
#include <stdio.h>
#include <avr/pgmspace.h>
#include <phi_interfaces.h>
#include <phi_prompt.h>

//Phi-2 shield LCD pin setting
#define LCD_RS 8
#define LCD_EN 9
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7

//Phi-2 shield buttons and channel pin assignments
#define lcd_rows 2
#define lcd_columns 16

#define analog_buttons_per_column 5 // Each analog pin has five buttons with resistors.
#define analog_buttons_per_row 1 // There are two analog pins in use.

#define name_length 5 // This is the max length of names.

char analog_mapping[]={'U','D','L','R','B'}; // This is an analog keypad.
byte analog_pins[]={0}; // The pin numbers are analog pin numbers.
//int values[]={0, 144, 342, 505, 742}; //These numbers need to increase monotonically. The 342 works better on my setup but you will need to change it back.
int values[]={50, 250, 450, 650, 850}; //Cheap keypad from ebay
phi_analog_keypads analog_keypad(analog_mapping, analog_pins, values, analog_buttons_per_row, analog_buttons_per_column);

// This serial keypad is for debugging.
phi_serial_keypads debug_keypad(&Serial,9600);

// The following sets up function keys for phi_prompt library
char up_keys[]={"U"}; ///< All keys that act as the up key are listed here.
char down_keys[]={"D"}; ///< All keys that act as the down key are listed here.
char left_keys[]={"L"}; ///< All keys that act as the left key are listed here.
char right_keys[]={"R"}; ///< All keys that act as the right key are listed here.
char enter_keys[]={"B"}; ///< All keys that act as the enter key are listed here.
char escape_keys[]={"A"}; ///< All keys that act as the escape key are listed here.
char * function_keys[]={up_keys,down_keys,left_keys,right_keys,enter_keys,escape_keys}; ///< All function key names are gathered here fhr phi_prompt.

// The following adds all available keypads as inputs for phi_prompt library
multiple_button_input * keypads[]={&analog_keypad, &debug_keypad,0};

// The following sets up LCD and other objects
//LiquidCrystal lcd(LCD_RS,LCD_EN,LCD_D4,LCD_D5,LCD_D6,LCD_D7); // Create the lcd object
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
    lcd.begin(lcd_columns, lcd_rows);
    lcd.print("Start");
    init_phi_prompt(&lcd,keypads,function_keys, lcd_columns, lcd_rows, '~'); // Supply the liquid crystal object, input keypads, and function key names. Also supply the column and row of the lcd, and indicator as '>'. You can also use '\x7e', which is a right arrow.
    Serial.begin(9600); // Serial is used as a debug keypad. This can be deleted after debug.
    Serial.write("Start scaning keypad..");
}

void loop()
{
    byte temp=analog_keypad.getKey(); // Use phi_keypads object to access the keypad
//  byte temp=pad1->getKey(); // Use the generic multiple_button_interface to access the same keypad
  delay(100);
  Serial.write(temp);
}

I appreciate any help since I new to arduino and phi_panel!

Mladen Bruck

I appreciate any help since I new to arduino and phi_panel!

If that's a real phi-panel then you should be able to get help from the developer of the panel, liudr, here --> Phi-panel | Liudr's Blog.

Don

PS: You might want to fix your link.

Hi Don...

I hoped mr. Liu would notice this post, since there is some of his activity here in last couple of months.

Link is ok, but from some strange reason last ")" is not notices as part of url.

:slight_smile:

Link is ok, but from some strange reason last ")" is not notices as part of url.

That often happens to me when I use the editing buttons so maybe it's a feature of the forum software.

Go back and edit your post to put the last ")" before the "[/url]".

It's always a good idea to preview your posts and check out the links before you actually submit them.

Don

Gee, I forgat to encode it into url pair… Corrected. Tnx to advice !