![]() See the GNU Lesser General Public License for more details. ProTrinketGamepad is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The License, or (at your option) any later version. Published by the Free Software Foundation, either version 3 of It under the terms of the GNU Lesser General Public License as ProTrinketGamepad is free software: you can redistribute it and/or modify ProTrinketGamepad uses V-USB ( ) to implement USB using a bitbang technique. Please see ProTrinketGamepad.h for usage documentation, examples are also included ProTrinketGamepad allows the user to implement a simple USB Gamepad using an Adafruit Pro Trinket (ATmega 328P based) Int center = range/2 // resting position valueĬonst float powerValue = 1.ProTrinketGamepad is Adafruit's Pro Trinket USB HID Arduino Library Int threshold = range/4 // resting threshold Int responseDelay = 5 // response delay of the mouse, in ms Int range = 12 // output range of X or Y movement (zero to range) set pin numbers for switch, joystick axes, and LEDĬonst int switchPin = 9 // switch to turn on and off mouse controlĬonst int mouseButton = 10 // input pin for the mouse pushButtonĬonst int xAxis = 1 // joystick X axis to A1Ĭonst int yAxis = 0 // joystick Y axis to A0Ĭonst int ledPin = 13 // Mouse control LED #include // include mouse library for Pro Trinket (3V or 5V) Version 1.0 Initial version for Adafruit Pro Trinket by Mike Barela ![]() Apart from powering the RFID at the correct voltage the signal lines will need conversion too, and in. The second issue is of level conversion for 5v to 3.3v parts. This sketch includes a pushbutton to toggle the mouse on and off.īased on software on by Tom Igoe placed in the public domain The first issue will be current draw - the Pro Trinket can only supply 150mA from its 5v regulator, your servo has an no-load draw of 150+ mA and you want to power an RFID as well. Over your mouse! Make sure you have control before you use the project. WARNING: When you use the new mouse, the Arduino takes Middle of the range, but that they vary within a threshold. The sketch assumes that the joystick resting values are around the * Pushbutton enable/disable the mouse entirely on D9 (optional) * 2-axis joystick connected to pins A0 and A1 with pushbutton on D10 Uses the joystick pushbutton to click the left mouse button This function checks if USB is connected, returns 0 if not connectedĬhar TrinketMouse.isConnected() // Starts the USB driver, place in the Arduino IDE setup routine:Ĭontrols a PC mouse from a joystick on an Adafruit Pro Trinket. TrinketMouse.move(0,0,0,MOUSEBTN_LEFT_MASK) // Click left mouse button TrinketMouse.move(5,-5,0,0) // Move 5 pixels up, 5 left from current location Void TrinketMouse.move(signed char x, signed char y, signed char wheel, uint8_t buttonMask) // makes a mouse movement, must be called at least once every 10ms, even if no movement MOUSEBTN_MIDDLE_MASK 0x04 // Middle Button MOUSEBTN_RIGHT_MASK 0x02 // Right buttom MOUSEBTN_LEFT_MASK 0x01 // Left button buttonMask - the following values may be ANDed to press mouse buttons: wheel - amount to tell the PC the mouse wheel has been spun (-127 to 127) y - the pixels to move in the vertical direction (-127 to 127) Note: this is in relation to the current mouse position, not absolute ![]() x - the number of pixels to move in the horizontal direction (-127 to 127) ![]() Copy Code // Starts the USB driver, place in the Arduino IDE setup routine:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |