SunFounder FruitKey User manual

Preface
About SunFounder
SunFounder is a technology company focused on Raspberry Pi and Arduino open source
community development. Committed to the promotion of open source culture, we strive to
bring the fun of electronics making to people all around the world and enable everyone to be
a maker. Our products include learning kits, development boards, robots, sensor modules and
development tools. In addition to high quality products, SunFounder also offers video tutorials
to help you build your own project. If you have interest in open source or making something
cool, welcome to join us! Visit www.sunfounder.com for more!
About FruitKey Kit
The SunFounder FruitKey is a USB keyboard-simulating control board designed for Arduino. You
can realize the ’sfunctionswithanArduinoboard.Itcanturnfruits,stairs,
play-doh, animals, tables, leaves, or even a pencil drawing into keyboard or gamepad. Just
connect it to some bananas , you can get a banana piano ;connectitto
some play-doh ,youwillgetagamepad ,andsoon.
The FruitKey is compatible with Arduino Uno, Leonardo, SunFounder Mars, and SunFounder Uno,
thus with one of these boards, we can make the FruitKey work. Here we use the SunFounder
Mars as an example, and other boards works the same way.
Note: You can download the code under LEARN -> Get tutorials on our website
www.sunfounder.com .
Free Support
If you have any TECHNICAL questions, add a topic under FORUM section on our website
and we'll reply as soon as possible.
For NON-TECH questions like order and shipment issues, please send an email to
[email protected]. You're also welcomed to share your projects on FORUM.
SunFounder

Contents
Components List........................................................................................................................................................ 1
What Is It?.....................................................................................................................................................................2
FruitKey + ? = (Keyboard)..............................................................................................................................4
How Does It Work?.................................................................................................................................................... 4
Software Installation..................................................................................................................................................7
Arduino..........................................................................................................................................................................7
Description....................................................................................................................................................................7
Install Arduino IDE.......................................................................................................................................................7
Add the Library......................................................................................................................................................... 10
What Can FruitKey Do?......................................................................................................................................... 12
Test................................................................................................................................................................................12
Simulated Keyboard................................................................................................................................................14
Change Functions of Keys.....................................................................................................................................17
Adjust Touch Sensitivity...........................................................................................................................................20
Adjust Responding Times....................................................................................................................................... 20
Tips.................................................................................................................................................................................21
SunFounder

1
Components List
No. Name Qty. Component
1SunFounderFruitKey 1
2Type-CUSBcable 1
3Type-A M-to-M USB cable
(for FruitKey) 1
4 Dual-head alligator clip cable 10
5 Male-to-Male DuPont wire 10
SunFounder

2
What Is It?
You may have heard about the popular kit named ,inwhichmanystuffsare
used as touch keyboards. There are quite a lot of videos showing how interesting projects it can
make including games, work, etc. In fact, the is a simple circuit board that
makes almost everything an input device for the computer. Therefore, stairs can be used as
piano keys, a banana as a keyboard, some play-doh to make a gamepad, even your family
members to do a synthesizer. It makes our life colorful and full of joy!
Now, what's amazing is that you can also make it with an Arduino board and SunFounder
FruitKey!
The SunFounder FruitKey is a USB keyboard-simulating control board designed for Arduino. You
can realize the ’sfunctionswithanArduinoboard.Itcanturnfruits,stairs,
play-doh, animals, tables, leaves, or even a pencil drawing into keyboard or gamepad. Just
connect it to some bananas , you can get a banana piano ;connectitto
some play-doh ,youwillgetagamepad ; draw buttons on a paper with a pencil
, then you turn this paper into a controller for the Pac-Man .
The SunFounder FruitKey works with the SunFounder Mars, SunFounder Uno, also the official
Arduino Uno and the Leonardo board. The SunFounder Mars is a self-designed microcontroller
compatible with the Arduino Uno in functionality and performance.
Note:Here we take the SunFounder Mars as an example, and other boards work the same
way.
SunFounder

3
The SunFounder Mars adopts also the ATMEGA328P as the processor, the same Optiboot
bootloader as Uno. And it has 14 digital I/O pins and 6 analog inputs and is featured with a
32KB program storage and 16MHz crystal oscillator and so on.
Multiple features make it unique: beautiful red PCB, parallel yellow and red pins, and a
beautiful red appearance. In technology, it uses FTDI232R for USB-to-serial and adopts Type-C,
the only USB port so far that supports reversible plug orientation. All the I/O ports are made with
two pins (male and female) in a row, for free to use – you can just plug Dupont wires regardless
of M or F.
A 5V power switch is added to control the board power, which may be expected by mass
hobbyists – you can switch off the board when it’s not in use, so as to avoid frequent plugging.
In addition, a reset button is set at the board side for operational convenience. To save space,
the ATmega328P Microcontroller is packaged in patch.
Together with SunFounder Mars, the FruitKey can be a simulated keyboard which is almost
"omnipotent".
SunFounder

4
FruitKey + ? = (Keyboard)
The FruitKey works on any conductive objects. You can also spray some water on the object’s
surface to make it work.
Preferred objects: banana, lead pencil, ketchup, lemon, and other plant; coin, jelly, cat (or
dog, etc.), or, human being.
How Does It Work?
As long as the object is conductive, the FruitKey can work with it. The principle is that a
single-chip microcomputer simulates some keys on a keyboard, and circuits will be connected
by a touch rather than a switch.
The SunFounder FruitKey uses a touch as the input signal. It adopts two-point touching switch.
The alligator clip cables are connected to the touching end and ground on the board, while
connected to the anode and cathode on the other end. When someone touches the anode
and cathode as a resistor, currents will flow through the power to ground on the board. Thus
the current value can be detected, then the touch.
Let your imagination go wild and turn anything into a keyboard!
SunFounder

5
Connect the FruitKey to two objects by alligator clips, such as your fingers and a lemon .
When you touch the when holding the other clip, an electric circuit is generated. Then
the FruitKey will send a signal – key pressed – to the computer via Mars, which be considered as
a real keyboard by the computer. The FruitKey can run on any programs or webpages.
The schematic diagram of the FruitKey:
SunFounder

6
Connect the six touch points A0-A5 of the FruitKey to 5V of Mars with a 1M pull-up resistor
between each. If there is no touch, A0-A5 are High level by default (that is, the default value of
A0-A5 is 1023). Since each of the six points is connected to a 0.1μF ceramic capacitor
respectively, when you touch the GND and one or two of A0-A5, the corresponding capacitor
will discharge, and the input voltage will be reduced, thus the input AD value.OncetheAD
value decreases to the threshold, it can be considered that the corresponding touching pad
has been triggered. Besides, we can connect six LEDs to digital pin6-pin11 as the signal
indicators for A0-A5 separately.
SunFounder

7
Software Installation
Note:
Before starting your own project, you must download the file FruitKey V1.0 for Arduino.zip on our
official website by visiting LEARN -> Get Tutorials -> FruitKey V1.0 for Arduino and unzip it.
Arduino
Description
Arduino is an open source platform with simple software and hardware. You can pick it up in
short time even if you are a beginner. It provides an integrated development environment (IDE)
for code compiling, compatible with multiple control boards. So you can just download the
Arduino IDE, upload the sketches (i.e. the code files) to the board, and then you can see
relative experimental phenomena. For more information, refer to http://www.arduino.cc.
Install Arduino IDE
The code in this kit is written based on Arduino, so you need to install the IDE first. Skip it if you
have done this.
Step 1: go to the arduino.cc website and click Download.Onthepage,checkthesoftwarelist
on the right side under Download the Arduino Software.
Find the one that suits your operation system and click to download. There are two versions of
Arduino for Windows: Installer or ZIP file. You're recommended to download the former.
SunFounder

8
Step 2: Double click the exe. file and the following window will show up. Click IAgree.The
following interface will show up.
Choose Next.
Click Browse to choose the installation path or enter a directory at the Destination Folder.
Click Install.
SunFounder

9
The following interface will show up. (Note: After the installing progress bar goes to the end, the
Close button may be enabled for some PC. Just click it to complete the installation.)
Then a prompt appears. Select Always trust software for "Adafruit Industries" and click Install.
SunFounder

10
Select Always trust software for "Arduino srl" and click Install.
After the installation is done, click Close. Then an Arduino icon will appear on the desktop:
Add the Library
1. Libraries are a collection of code that makes it easy for you to connect to a sensor, display,
module, etc. In this kit, you will need to add one library to the Arduino libraries folder:
UsbKeyboard.zip.
2. Select Sketch -> Import Library -> Add Library.
SunFounder

11
3. Find the UsbKeyboard library under the \FruitKey V1.0 for Arduino\Code\Library.Click
Open.
4. When you see Library added to your libraries. Check “Include library” menu,itmeansyou
have added the library successfully. Please use the same method to add other libraries
then.
SunFounder

12
What Can FruitKey Do?
With this kit,
*Designers can create amazing art works.
*Engineers can develop all kinds of interesting games.
*Educators can enlighten children’s creativity.
*Unlimited creative space can be available for geeks.
Test
Before using the FruitKey, let’s test its sensitivity first.
Principle
We have connected 6 LEDs to pin6-pin12 separately on the FruitKey, which lead to A0-A5. Clip
one end of the alligator clip cable to the hole pairs of the GND while leaving the other end
dangling, and another cable to one hole pairs of A0-A5 also with the other end dangling.
Touch the dangling end of the two cables, and the corresponding LED will brighten.
Procedures
Step 1: Insert the FruitKey to the SunFounder Mars board, and connect the Mars to your
computer by a Type-C USB Cable. The green LED (power indicator) on the boards will brighten
at the same time. The computer will install the driver automatically, and the Arduino
Uno(COMXX) will prompt at the taskbar after a while.
Type-C USB cable
SunFounder

13
Step 2: Open FruitKey V1.0 for Arduino\Code\Test\Test.ino
Step 3: Select a board. Here we select Arduino Uno.
Then select a Port.HereisCOM60 (yours should be different).
Step 4: Upload the code to the board.
When you see Done Uploading prompts, which indicates the upload is finished, you can start
the test then!
Step 5: Clip one end of an alligator clip cable to the GND hole pairs, and leave the other end
dangling, then snap another cable into A0 hole pairs, and the other end dangling. Touch the
two dangling ends, and you will find the LED 1 brighten, and become dim as soon as you let
them go. To test the sensitivity of all the hole pairs of A0-A5 one by one, you can repeat the
above operations; as for the rest five cables, try one by one in a workable circuit you've
completed.
So, everything works just fine. Now let’s try to use the FruitKey!
SunFounder

14
Simulated Keyboard
The main function of the SunFounder FruitKey is to make a simulated keyboard. But before that,
we need to do some preparation.
1) Open Handle.ino under the path of FruitKey V1.0 for Arduino\Code\Handle,thenupload
the code to the board
2) Remove the Type-C USB cable, and connect the FruitKey to the computer with a USB
type-A M-to-M cable. As the driver will be installed automatically, it may take a little time.
USB type-A M-to-M cable
SunFounder

15
Note: Operating Systems including WIN7,XP,andMac O SX can recognize the board with the
driver automatically. If it cannot be recognized by your computer, just remove the USB cable
and replug to try.
Now, everything is ready! Just fully utilize your imagination to turn anything into a keyboard.
Nothing is impossible!
Clip one end of the six alligator clip cables onto the holes, and the other end to any desired
conductive stuffs as you wish.
The default functions of A0-A5 in Handle.ino are shown as below:
A0 A1 A2 A3 A4 A5
Left Up Down Right Space Enter
Open a game or software, try these six keys - Up, Down, Left, Right, Space, and Enter by
touching the corresponding conductive objects. Let’s try the following games now!
SunFounder

16
GAME-Pac Man
GAME-Flappy Bird
SunFounder

17
Change Functions of Keys
We use different types of key when we play different games or use varied software, so we need
to replace the function in the FruitKey, which is very simple.
The SunFounder FruitKey is designed as a control board based on Arduino to make a keyboard
with rich key functions. Therefore, we can change the function of the keys via checking the
libraries.
1) Find the folder in which you saved UsbKeyboard previously. Select File->Preferences,anda
window will pop up, on which you can see the location of the folder. Please note that the
path may differ from what's shown in this case.
2) Then go to this path, and you can see a libraries folder.
3) Open usb_keymap.h under
C:\Users\sunfounder\Documents\Arduino\libraries\UsbKeyboard
SunFounder

18
4) This usb_keymap.h is to define some keys, such as space and Enter.
Open the handle.ino file, find the lines for key control.
5) To change the keys Up,Down,Left,andRight,withkeysO,P,Q,andR, you just need to
modify the corresponding key value.
SunFounder
Table of contents