element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Rapid Prototyping – Custom USB Mouse
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: benmatrix
  • Date Created: 9 Apr 2015 3:45 PM Date Created
  • Views 432 views
  • Likes 2 likes
  • Comments 0 comments
  • flowcode
  • etch-a-sketch
  • encoder
  • usb
  • ecio
  • mouse
Related
Recommended

Rapid Prototyping – Custom USB Mouse

benmatrix
benmatrix
9 Apr 2015

Using Flowcode it is possible to create a wide range of electronics devices in a short space of time.

 

A good example of this is a USB mouse in that it is very simple to achieve but also has a wide range of uses.

 

Here is a list of a few uses I could think of:

  • Creating your own USB mouse
  • Creating your own USB graphics tablet using a restive or capacitive panel
  • Creating your own USB Etch-A-Sketch using encoders or potentiometers
  • Automated clicking on a button at a certain time of the day or after a certain delay
  • Automated mouse entry to do specific repetitive jobs
  • Mouse controlled via Wifi / Bluetooth / Ethernet connection
  • April fools joke “ghostly mouse”

 

Of course you don’t just have to make a mouse, a custom USB keyboard or joypad would have just as many uses, however so we don’t get sidetracked we will remain on the subject of the mouse for now.

 

mouse-e1428592020870.jpg

 

Microcontroller Hardware


First lets look at the hardware we will be using. The ECIO40P is a PIC18F based device which has a low cost and features USB connectivity out of the box with zero setup. This means that it is very straightforward to create your firmware. Also programs designed for this will work just as well on the ECIO28P or the new more powerful dsPIC33EP based ECIO40P16. You can also use any PIC or dsPIC chip with hardware USB support but the initial setup may be a little more tricky as you have to get the oscillator speed and configuration settings right for your specific chip and hardware.

 

ECIO-page-header-300x126.jpg

 

We also use E-blocks in the examples as they are again ideal for plug and play or rapid prototype functionality. However you can always refer to the E-block datasheet which provides the schematic allowing you to replicate the circuitry using electronics you have to hand.

 

 

Flowcode USB HID Component


The USB HID component has a number of properties that we must first setup correctly.

 

USBHIDProps-1024x477.jpg

 

The product and vendor ID are your USB identifiers and should be unique for every USB device you create. If you are making a device for personal use then you can use our vendor ID of 12BF and a product ID of your choosing. Take care not to use our product IDs or your EB006 or ECIO may suddenly stop working. If you are making a commercial product to sell then you will need to purchase your own ID from the USB.org.

 

The descriptor select property allows you to pick from the pre-done Mouse and Keyboard descriptor or allows you to add your own HID descriptor for say your custom USB joypad. There is a descriptor tool available from USB.org to help designing your own HID descriptor.

 

The transmit and receive packets sizes are linked to the descriptor so for example our standard Mouse descriptor sends three bytes and receives no bytes. Byte0 represents the mouse buttons, Byte1 represents the X movement from -128 to +127 and Byte2 represents the Y movement from -128 to + 127.

 

Both of the examples below are quite similar in the terms that we initialise the USB component, do a bit of simple I/O and then use this to determine the values we send to the PC via USB.

 

 

Rapid Prototype 1 – Keypad based USB mouse


Parts list: ECIO40P, EB061 ECIO Applications Board, EB014 Keypad

 

Flowcode program: USB Mouse Example

 

Here is a diagram of the mouse functions based on the keypad button being pressed.

 

KeypadMouseLayout-234x300.png

 

The speed of the mouse is based on the variable Speed which is assigned as 10 near the start of the program. This may be a bit fast for some users so you could try changing the speed to 1 or 2 for a more controllable mouse cursor. This could be further improved by resetting the speed to 0 when no keypad buttons are pressed and slowly increasing the speed when a button is pressed.

 

The keypad can only accept one button press at a time due to the restrictions of the keypad circuitry, however using individual switches you would be able to press multiple buttons at the same time.

 

ECIO_Keypad_Mouse-300x180.jpg

 

Rapid Prototype 2 – Encoder based Etch-A-Sketch style USB mouse


Ever wanted to be able to draw on your PC like you did on your old Etch-A-Sketch? No I didn’t think so, however there are times where a pixel perfect controlled mouse can be very useful.

 

Parts list: ECIO40P, EB061 ECIO Applications Board, EB073 Rotary Encoder

 

Flowcode program: USB Encoder Example

 

Encoder 1 controls the mouse X position, rotating clockwise moves the cursor to the right and anti-clockwise moves the cursor to the left. Encoder 2 controls the mouse Y position, rotating clockwise moves the cursor down while anti-clockwise moves the cursor up. Switch SW1 on the encoder board can be used as the left mouse button enabling you to easily use the hardware with drawing packages etc.

 

Click the switch once and the LED on the Encoders board will light informing you that the left mouse button is now being held down. Click the switch again to release the left mouse button and switch off the LED.

 

ECIO_Encoder_mouse-300x159.jpg

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube