(home)

Project Log : USB Stealth Twiddler

Description

Project log for development of USB Stealth Twiddler and associated code.

Inspired by Stealth USB CapsLocker but mainly an excuse for creating a "complete" project with my Arduino/AVRUSB integration and maybe having something to take to Kiwicon 2K8.

See also: Learning About Arduino and AVR-USB, ProjectLogArduinoUSB

Code

Notes

void setup() {
  pinMode(8, INPUT);
  pinMode(9, INPUT);

  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);

  // TODO: Use analogWrite for PWM.
  //digitalWrite(9, LOW); 
  //digitalWrite(8, HIGH);

  
}

void loop () {
  digitalWrite(8, LOW); 
  digitalWrite(9, HIGH);

  delay(250);

  digitalWrite(9, LOW); 
  digitalWrite(8, HIGH);

  delay(250);

}
cd <path>/arduino-0012/hardware/libraries/
cp -R /<path>/arduinousb_release_001/libraries/UsbKeyboard .
cd UsbKeyboard/

Patch usbconfig.h file:

--- usbconfig.h	2008-09-24 22:19:32.000000000 +1200
+++ usbconfig.h~	2008-09-24 22:08:54.000000000 +1200
@@ -39,13 +39,13 @@

 /* ----------------------- Optional Hardware Config ------------------------ */

-#define USB_CFG_PULLUP_IOPORTNAME   D /* */
+/* #define USB_CFG_PULLUP_IOPORTNAME   D */
 /* If you connect the 1.5k pullup resistor from D- to a port pin instead of
  * V+, you can connect and disconnect the device from firmware by calling
  * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
  * This constant defines the port on which the pullup resistor is connected.
  */
-#define USB_CFG_PULLUP_BIT          6 /* */
+/* #define USB_CFG_PULLUP_BIT          4 */
 /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
  * above) where the 1.5k pullup resistor is connected. See description
  * above for details.
@@ -138,7 +138,7 @@
  * obdev's free shared VID/PID pair. See the file USBID-License.txt for
  * details. 
  */
-#define USB_CFG_DEVICE_NAME     'T', 'w', 'i', 'd', 'd', 'l', 'r'
+#define USB_CFG_DEVICE_NAME     'H', 'I', 'D', 'K', 'e', 'y', 's'
 #define USB_CFG_DEVICE_NAME_LEN 7
 /* Same as above for the device name. If you don't want a device name, undefine
  * the macros. See the file USBID-License.txt before you assign a name.

Recompile

avr-g++  -Wall -Os -I. -DUSB_CFG_CLOCK_KHZ=16000  -mmcu=atmega168  -c usbdrvasm.S  -c usbdrv.c

(I actually used this:)

/<path>/arduino-0012/hardware/tools/avr/bin/avr-g++  -Wall -Os -I. -DUSB_CFG_CLOCK_KHZ=16000  -mmcu=atmega168  -c usbdrvasm.S  -c usbdrv.c

Also, got a couple of warnings...

usbdrv.c:75: warning: only initialized variables can be placed into program memory area
usbdrv.c:85: warning: only initialized variables can be placed into program memory area
usbdrv.c:94: warning: only initialized variables can be placed into program memory area
usbdrv.c:114: warning: only initialized variables can be placed into program memory area
usbdrv.c:143: warning: only initialized variables can be placed into program memory area
code@rancidbacon.com