[Coco] Arduino as a Mouse/Keyboard interface?

Frank Swygert farna at amc-mag.com
Wed Jul 4 19:55:19 EDT 2012


Mark, the reason I mentioned the Leonardo board as a keyboard interface 
is because the Arduino site SPECIFICALLY mentions it can be used to 
interface a keyboard. (http://arduino.cc/en/Main/ArduinoBoardLeonardo)
--------------------
"The Arduino Leonardo is a microcontroller board based on the ATmega32u4 
(datasheet 
<http://www.atmel.com/dyn/resources/prod_documents/7766S.pdf>). It has 
20 digital input/output pins (of which 7 can be used as PWM outputs and 
12 as analog inputs), a 16 MHz crystal oscillator, a micro USB 
connection, a power jack, an ICSP header, and a reset button. It 
contains everything needed to support the microcontroller; simply 
connect it to a computer with a USB cable or power it with a AC-to-DC 
adapter or battery to get started.

The Leonardo differs from all preceding boards in that the ATmega32u4 
has built-in USB communication, eliminating the need for a secondary 
processor. This allows the Leonardo to appear to a connected computer as 
a mouse and keyboard, in addition to a virtual (CDC) serial / COM port. 
It also has other implications for the behavior of the board; these are 
detailed on the getting started page 
<http://arduino.cc/en/Guide/ArduinoLeonardo>."
--------------------

I might be misinterpreting the above, but another site specifically 
mentioned that a USB keyboard can be plugged into the USB port and that 
there was software for the Leonardo board that would read the keyboard.

This led me to believe the I/O pins could possibly be connected directly 
to the keyboard connector or the keyboard PIA lines and have the 
Leonardo processor translate the PC keyboard to the data the CoCo needs:
----------------------
"Each of the 20 digital i/o pins on the Uno can be used as an input or 
output, using pinMode() <http://arduino.cc/en/Reference/PinMode>, 
digitalWrite() <http://arduino.cc/en/Reference/DigitalWrite>, and 
digitalRead() <http://arduino.cc/en/Reference/DigitalRead> functions. 
They operate at 5 volts. Each pin can provide or receive a maximum of 40 
mA and has an internal pull-up resistor (disconnected by default) of 
20-50 kOhms. In addition, some pins have specialized functions:"
----------------------

I know just enough  about electronics to have some reasonable ideas and 
understand theory, not enough to put it into practice. Some have already 
surmised that the 16MHz processor (w/32K flash, 2.5K SRAM, and 1K 
EEPROM) might not be fast enough to do this in software, and/or that a 
cross switch would be more efficient. I would have thought it could all 
be done fast enough in software being that the Leonardo processor is at 
least 8x faster than a CoCo3 (processor speed wise, I know there are 
other factors to consider for actual processing speed).

After a bit of reading I see that I *did* misunderstand. The keyboard 
and mouse libraries for the Leonardo make a PC think the Leonardo is a 
keyboard or mouse, they don't allow you to connect a keyboard or mouse. 
You can send keystrokes to the PC. I don't see why it won't work the 
other way around, but a program would have to be written from scratch to 
do it. If it can emulate a keyboard, it should be able to read a 
keyboard. Sounds right and logical, but reality might be different...

-- 
Frank Swygert
Editor - American Motors Cars Magazine
www.amc-mag.com




More information about the Coco mailing list