I think my mbed is broken?

13 Oct 2010 . Edited: 13 Oct 2010

Hi,

Just tried my mbed after it being in a drawer for quite a while - and tried to use the AnalogIn on p20, and tried to use my finger to touch it so that it would trigger an event. And it..err..didn't. The built-in LEDs work fine, and so does p20's DigitalOut (haven't tried any other pins), but AnalogIn just doesn't work...so is it a problem with my code

 

 

 

#include "mbed.h"

DigitalOut myled(LED2);
AnalogIn myIn(p20);

int main() {
while (1){
if(myIn > 0.3) {
myled = 1;
} else {
myled = 0;
}
}
}




13 Oct 2010 . Edited: 13 Oct 2010

Touching pins like that isn't a good idea, it's possible to zap the input with a static discharge. You should use a pot to provide a variable voltage to the input, or a couple of resistors as a divider could be used for a fixed voltage.

That code won't trigger an event, like an interrupt, it will read the ADC and light the LED if the input voltage is above 1.1V

13 Oct 2010

Try wearing rubber shoes or running around with a wolly jumper on brfore touching it! Seriously though, as said above, touching the pins isn't a good idea [ref]. But even so, have you not considered you just grounded yourself? This one sure way I would _never_ test if my AnalogIn was working. Who knows what voltage your body is at!

13 Oct 2010

Hi Dom,

Leon and Andy are right to be warning about this sort of thing, but I don't want you to get too distracted/worried about this. I suspect all is fine.

The main thing i'd try is build a proper circuit! i.e. whilst running your program, connect a wire between the analogIn pin and VOUT (3.3v) or GND (0v), and see the difference. Also, be careful if you are just touching it on pins that you are getting a proper connection; sometimes touching to top of the pins where soldered is unreliable, so really best to be doing on a breadboard.

Tell us if you get it working!

Simon