build a "push button" on Mbed

18 Jun 2011

hello,

i will a pushbutton install on mbed. how i do that??

do you have a picture with the connectors?

I need a simple code for Hello World:

1. i push the Button 2. Tera Term say "Hello Word"

Can anybody help me??

thanks!!!!

18 Jun 2011

Hello, try connect pushbutton on pin 20 and pin VOUT. Compile code bellow and load to mbed. Default is 9600 baud speed on com to terminal.

#include "mbed.h"

DigitalIn pushbutton(p20); //Define pushbutton on pin 20

Serial pc(USBTX, USBRX); // Define serial TX RX
 
int main() {
    while(1) {
    if (pushbutton) {

pc.printf("Hello World");

wait(1);  // Waits 1 second and print Hello World again
     
}
}
}
18 Jun 2011

If You have not set connection to terminal, try http://mbed.org/handbook/Windows-serial-configuration

And use this modified code:

#include "mbed.h"

DigitalIn pushbutton(p20); //Define pushbutton on pin 20

Serial pc(USBTX, USBRX); // Define serial TX RX
 
int main() {
    while(1) {
    if (pushbutton) {

pc.printf("Hello World\r\n"); //Print each on each line

wait(1);  // Waits 1 second and print Hello World again if button still pressed
     
}
}
}

18 Jun 2011

thanks for your help.

the software is simple and for me as a beginner easy for understanding.

Can you tell me, how i install the pushbutton on the hardware.

3,3V-Pushbutton - P20

is that right?

18 Jun 2011

Yes, 3,3V - pushbutton - P20.

18 Jun 2011

"The pin input is logic '0' for any voltage on the pin below 0.8v, and '1' for any voltage above 2.0v. By default, the DigitalIn is setup with an internal pull-down resistor.

need i a pull-down resistor??

2K resistor?? ok?

18 Jun 2011

I am newbie too. Hope this will help You.

18 Jun 2011

welcome in the club :-)

18 Jun 2011

Thank You

19 Jun 2011

Answer to me:

You must take a resitor to limit the power(Amp).

I had taken a 1K resistor.

so 3,3V to Resistor to pushbutton to pin 20

and all is wonderful

24 Jun 2011

...Ooops. I decided not to bother with resistors (I don't have any around, anyway; I ended up using a LED when I needed one for my LCD screen, haha) for my buttons.

The circuit does work, though. :/