Main Site Documentation

How to read analog pin of LCD KeyPad Shield For Arduino on FEZ Cerbuino Bee


#1

I purchased LCD KeyPad Shield For Arduino SKU: DFR0009 (http://www.dfrobot.com/wiki/index.php/LCD_KeyPad_Shield_For_Arduino_SKU:_DFR0009)

Now I try to read analog pin 0:


AnalogInput buttons = new AnalogInput(Cpu.AnalogChannel.ANALOG_0);

while (true)
{
    try
    {
          var val = buttons.ReadRaw();
          Debug.Print(val.ToString());
          Thread.Sleep(500);
     }
     catch (Exception ex)
     {
          Debug.Print(ex.Message);
     }
}

I see numbers in Output, but they does not change significantly when I press shield buttons.

Is my code correct?


#2

Do you always read the max? I think those buttons are connected to 5v instead of 3.3v.


#3

No, values are something like 348 ±1 or 0.852 if I use Read().

Do you mean I do not provide enough voltage for shield?


#4

You haven’t told us what device you have, have you ?

The VCC connection on that shield presumably goes to 5v, because for Arduino that’s usual. Most options you have with netmf are NOT 5v tolerant on the analog multiplexer, which means you could damage the processor if you haven’t already done so.


#5

also just thinking how you can safely test this. Do you have a multimeter ? You should measure the resistance to GND for the a0 pin as you press the buttons, you can see in the schematic the resistor values that should add up as you press and multi-press the buttons. You can also use the multimeter to measure the voltage on the pin to confirm the voltage you initially see, and again as it changes as you press buttons - but you’ll need to supply GND and 5v power to the shield to have that work.


#6

@ Brett - It’s written in topic title, Cerbuino Bee.
Yes, I have multimeter, I’ll try to measure that resistance.

How can I do it safely? I mean I can not just plug in external 5V DC adaptor to mainboard as it will damage processor.


#7

you’re right, I didn’t see that on the “reply” page.

The way to safely connect 5v up is to have a 5v power source and connect it explicitly, not via the shield plugged into the Cerbuino. That means a 5v wall wart/power adapter (what ever they’re called in your part of the world) and some wires - but you could also use the 5v from the cerbuino by just running temporary jumper wires from the cerbuino over to the shield (you need GND too obviously). EDIT: Just to reiterate my earlier comment - you are trying to test the shield while it is NOT CONNECTED to the mainboard.

Looks like I already dug out the answer to this one from the data sheets before.

https://www.ghielectronics.com/community/forum/topic?id=12305&page=1

Do NOT connect 5v to the Analog in pins. If you’ve already done that, that may be why it’s reading a constant value now. You can test this out without the shield attached, and you can connect the A0 pin to GND and see if it still reads your value - if so, sorry, you’re bust.


#8

@ Brett - Thanks for valuable info, but I think I’m too noob at electronics and can not measure that resistance (multimeter does not change it value, maybe I connect wrong pins).
I’ll just wait for additional components arrival specially for Cerbuino and see for sure is my board still alive.

Thanks again!


#9

If the resistance doesn’t change, then the shield isn’t working as expected (or you messed up with the pins, but I don’t necessarily think so, the value you read isn’t any different which matches this). What resistance do you see in “stable state”?

What other components are on their way ? Do you have access to a potentiometer that we can hook up to vary the voltage ?

Also, add your location to your profile - there might be someone local who can assist