10 years, 3 months ago.

Can I use my keyboard to control stuff?

Hello,

I am new to microcontrollers and programming in general and I was wondering if it is possible to turn things on and off using certain keys on the keyboard? I am trying to design a simple model submarine and have four motors which I would like to control using the arrow keys (I want to keep just one cable running from the computer to the sub).

Thank you

David

3 Answers

10 years, 3 months ago.

Thank you for those answers. I had originally planned on using two mbeds, one in the sub and another one on the top with joystick controllers, however it is for a university project and I don't have a great deal of time, so I was thinking if I could control it directly from the laptop to the bottom mbed it might be simpler. Is there a way of using longer USB cabling? I would need about 30m of cable.

Thanks again

David

USB standards dont allow 30m of cablelength. You could possibly use some (powered) repeaters, but that will be expensive and hard to waterproof.... I would go for a simple serialcable that possibly connects to a USB to serial converter on the laptop side and interfaces directly with mbed using an RS232 driver (eg MAX3232) on the sub side.

posted by Wim Huiskamp 13 Jan 2014

Thank you for that Wim.

posted by David McIntyre 17 Jan 2014
10 years, 3 months ago.

Quick answer: yes. However, it depends on what you have in mind. A PC running a terminal application and sending character keys would work. You probably cant use a USB cable since that only works reliably on short distances. A regular rs232 serial port is more robust but needs receivers and drivers on the mbed side ( eg max 3232). You could also use a standalone Ps2 PC keyboard with some software on the mbed side. Dedicated keyboards with or without an mbed on the sender side would be another option.

10 years, 3 months ago.

An USB Keyboard will work also if your device is supported by the USBHost class. Host is important, do not use the USBdevice classes, there your device would emulate a keyboard.