V-USB and arduino

Hello,

recently I've seen a V-USB web page which enable simple non USB avr chips to have USB communication with PC and imitate HID devices. I'm interested in keyboard.

I can't get how to include files which are downloadable from their web page in my project.

  1. my main task is to upload code on atmega328 using Arduino Uno.
  2. then take atmega328 chip on the breadboard and connect to PC
  3. make chip act like HID (keyboard)

my main misunderstood is that I can't get how to upload this files on atmega chip and make it work
please help me, it would be very helpful for me.

Ok, but when i add this folder Download V-USB then i extract it and add to the library folder of arduino IDE. It doesn't work, it even can't see this library.

So Please help me, it would be very helpful for me.

I'm interested in keyboard.

There is a library for that from one of the forum members:
http://code.rancidbacon.com/ProjectLogArduinoUSB

I have a thread using the library here:
http://code.rancidbacon.com/ProjectLogArduinoUSB
More of my stuff around V-USB:
http://www.hackster.io/rayburne/arduino-to-excel-using-v-usb
http://www.hackster.io/rayburne/analog-digital-port-viewer-usb
http://www.hackster.io/rayburne/chachka-trinket-attiny85-clone
http://www.hackster.io/rayburne/trinket-firmware-exorcism
And a bunch more stuff around this forum... but when using the forum search for "V-USB", remove the dash!!!

It is easy. It works. But it is USB 1.1, so some of the newest machines may fuss a bit but usually if you plug in and unplug the adapter, you can get HID to load ... NO DRIVERS are required for Windows.

Ray

Hello,

I have question on compiling and using the library. Which one should i get (there is a 005.zip available, but in the log only the 004)? Does it compile with 1.0.4/5 or only with 16 as mentioned in the caveat?
I tried it for hours, but no result (Duemilanove/UNo: no HID shown on Windows/mac).

My adapter is working fine as an usb-asp Programmer (same schematics + 10uF cap).

Thanks

themroc:
I have question on compiling and using the library.
Which one should i get (there is a 005.zip available, but in the log only the 004)?
Does it compile with 1.0.4/5 or only with 16 as mentioned in the caveat?
I tried it for hours, but no result (Duemilanove/UNo: no HID shown on Windows/mac).
My adapter is working fine as an usb-asp Programmer (same schematics + 10uF cap).

GUI: Arduino 1.0.5r2
library: https://code.google.com/p/vusb-for-arduino/ (latest version is ...005.ZIP)

All of the V-USB code requires that the hardware, resistors and zeners, are working correctly. If you compile without error, and you Arduino does not enumerate as HID 1.1 on the USB bus you have a hardware problem. Having completed around 20 of these projects, I will tell you that it is almost always the 3.6Volt zener diodes that are an issue. They are critical.

I gave you my reference project link which I verified compiles on 1.0.5r2
I cannot help you with the rest other than to reference were you may purchase the small hardware.
See Parts you will need, here:
http://www.hackster.io/rayburne/arduino-to-excel-using-v-usb

Ray

Thanks for the reply,

I will give it another try. It compiles with no problems.
Unfortunately the zener diodes are working within my other projekt (usbasp like programmer), but I will try another pair. I just wanted to rebuilt some makey makeys with kids on shrimps.

That didn´t work, so I tried a basic version with simple usbkeyboard and there I got stuck. I will install the 1.05 and try it again.

Chris

themroc:
Thanks for the reply,

I will give it another try. It compiles with no problems.
Unfortunately the zener diodes are working within my other projekt (usbasp like programmer), but I will try another pair. I just wanted to rebuilt some makey makeys with kids on shrimps.

http://fromscratched.nl/index.php/shrimpkey-maak-je-eigen-makeymakey-deel-3/?lang=en
...
Chris

Chris,

I was unaware you had V-USB experience, so I regret if I sounded a bit short in response. You cannot believe the amount of private V-USB requests for help ...
Anyway, I posted a thread here:
http://forum.arduino.cc/index.php?topic=195003.0
Showing V-USB adapters for UNO, Pro Mini, Nano, and Bare Board.

Since you have a known good supply of zeners, I am at a loss as to what is going on. I'm in the middle of a new project for my Hackster blog, but I will try and take a deeper look at your code ASAP.

Regards,

Ray
http://www.hackster.io/rayburne

Thanks Ray for your immediate replys,
your link is really helpful, but the main problem exists.

I think it is definitely a software problem, but i can´t figure out where.
I tried another "fresh" computer with fresh ARduino (1.0and library (005) installed. On my official uno-board the basic example sketch from the library compiled with some warnings in US. It runs, but does not contact with the PC (no plong sound on windows). The UNO starts immediately, but does not contact (there is no connect/disconnect section in the basic example).

...
In file included from UsbKeyboardDemo1.ino:1:
D:\arduino-1.0.5-r2-windows\arduino-1.0.5-r2\libraries\UsbKeyboard/UsbKeyboard.h:36: warning: only initialized variables can be placed into program memory area
UsbKeyboardDemo1.ino: In function 'void delayMs(unsigned int)':
UsbKeyboardDemo1.ino:23: warning: comparison between signed and unsigned integer expressions

Seems that some HID descriptors are loaded in this line in UsbKeyboard.h to program memory. Maybe it does not work without it, but you could compile it and it worked for you, why not for me :frowning:

best regards

chris

I think it is definitely a software problem, but i can´t figure out where.
I tried another "fresh" computer with fresh ARduino (1.0and library (005) installed. On my official uno-board the basic example sketch from the library compiled with some warnings in US.

I do not know. I'm working on another project right now and do not have 1.0.5r2 installed, but the compile went great with the new 1.5 beta.

Here is part of the verbose output from GUI 1.5.6r2 Rest is in the ZIPs

C:\Program Files\arduino156r2\hardware\tools\avr\bin\avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp/USB_HID_AnalogX6_D8.cpp.elf C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp\USB_HID_AnalogX6_D8.cpp.o C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp\UsbKeyboard\usbdrvasm.S.o C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp\UsbKeyboard\oddebug.c.o C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp\UsbKeyboard\usbdrv.c.o C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp/core.a -LC:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp -lm 
C:\Program Files\arduino156r2\hardware\tools\avr\bin\avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp/USB_HID_AnalogX6_D8.cpp.elf C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp/USB_HID_AnalogX6_D8.cpp.eep 
C:\Program Files\arduino156r2\hardware\tools\avr\bin\avr-objcopy -O ihex -R .eeprom C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp/USB_HID_AnalogX6_D8.cpp.elf C:\DOCUME~1\Mickey\LOCALS~1\Temp\build301945727080043118.tmp/USB_HID_AnalogX6_D8.cpp.hex 

[b]Sketch uses 8,278 bytes (25%) of program storage space. Maximum is 32,256 bytes.
Global variables use 375 bytes (18%) of dynamic memory, leaving 1,673 bytes for local variables. Maximum is 2,048 bytes.[/b]

Attached are the ZIPs if you want to try and upload it via AVRDUDE (HEX is all you really need). It is compiled for UNO, so the HEX is in the archive with the whole compile... in case you wish chase the issue down.

Ray

VerboseCompile.txt (21.7 KB)

USB_HID_AnalogX6_D8.zip (2.24 KB)

vUSBtest.zip (266 KB)

More Info on Compile Failure:

Since Microsoft killed-off WinXP support and since 1/2 of Arduino development requires research and Internet access, I moved my development from WinXP2002SP3 to WinVista2007SP2... both notebooks having 2G of RAM.

When I posted the compile binaries recently, they came from the WinXP machine which has a copy of the pre-migration source code and was compiled under the Arduino1.5.6r2 exec dated 3/18/2014. The JAVA version on the XP notebook is 1.7.0_45_b18. No errors were reported during the compile.

However, moving that entire Arduino environment to the VistaSP2 machine and attempting the same compile fails... and fails miserably. The errors imply issues with the library file, exact same library file as on the XP box.

In file included from USB_HID_AnalogX6_D8.ino:8:
C:\Users\owner\Documents\Arduino\libraries\UsbKeyboard/UsbKeyboard.h:38: error: conflicting declaration 'const char usbDescriptorHidReport [35]'
C:\Users\owner\Documents\Arduino\libraries\UsbKeyboard/usbdrv.h:491: error: 'usbDescriptorHidReport' has a previous declaration as 'char usbDescriptorHidReport []'

JAVA on the Vista machine reports:

C:\>java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b14)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)

AVR-GCC on the Vista (and WinXP machine):

C:\Program Files\arduino156r2\hardware\tools\avr\bin>avr-c++ -v
Using built-in specs.
Target: avr
Configured with: ../gcc-4.3.3/configure --enable-win32-registry=WinAVR-20100110 --with-gmp=/usr/local --with-mpfr=/usr/local --prefi
x=/c/WinAVR --target=avr --enable-languages=c,c++,objc --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp
 --disable-nls --with-pkgversion='WinAVR 20100110' --with-bugurl='URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&fun
c=browse'
Thread model: single
gcc version 4.3.3 (WinAVR 20100110)

So, clearly there is something different in the environment that is affecting the build process as the same Arduino GUI, boards.txt, lilbraries, and AVR-GCC installation is active on both XP and Vista. Differences are vast, including the OS and all the most current MS patches on both environment and the JAVA libraries, etc.

V-USB was/is just a play diversion for me as it makes good blog posts, but I do not do anything serious with the product (but i do own my own VID/PID pairs just in case!) So, I do not intend on pursuing the fault. With the entire Arduino and JAVA code in constant flux and with MS screwing around with security patches (I run the Arduino.exe as Administrator... but!) it simply is not worth my time. If I want to play with V-USB I will go back to the XP machine and just keep it off-line.

Hopefully the above details will make anyone that is having issues suspect that they are not going crazy although crazy and 'programmer' do pretty much go hand-in-hand. :smiley:

Ray

Dear Ray,

yes windows is awful, but I have the XP Version:). After getting the 1,5k instead of 2,2k Resistor in D- now with your precompiled HEX-file it runs instantly (the "plong" sound appeared and after resetting the UNO it worked).
Your sketch in this version worked for me too (after compiling and uploading).

Now compiling the USBKeyboard1-Demo that comes with the library didn´t, so I changed some lines in USBKeyboard1 (#include <avr/pgmspace.h> and the USBdevice.connect() sequence according to your sketch) and tada it worked!

It is not a serious project, but the kids will have fun (and they should build their own Arduino-based Makeys)!

Many, many thanks from Berlin,
Chris

It is not a serious project, but the kids will have fun (and they should build their own Arduino-based Makeys)!

Many, many thanks from Berlin,
Chris

Fantastic!

Ray

Afterthought:

After getting the 1,5k instead of 2,2k Resistor in D-

If you have an oscilloscope, you may wish to breadboard the resistor + zener and with a 3.3V square wave into the network, observe the zener knee with 1,5K and 2,2K resistors to see what the V' shift really is... For the Vishay diodes I use, 1,8K seems to be the magic value.

After modifying the code mentioned above (Shrimpkey) and compiling with your library (the provided one with the Shrimpkey-code failed), the makey-clone works fine with keyboard commands.

But the original Makey has a Mouseclick. Is it possible to get a Mouseclick send over USBKeyboard? Do I have to change some report descriptors (like http://www.instructables.com/id/USB-Wii-Classic-Controller/step13/Bonus-Keyboard-and-Mouse/) and adapt the code or is their possibly another trick?

As it works with the other Keys its ok, but would be fine to have this Mouseclick-Feature (for simple use of the Makey apps).

Unfortunately I don´t own an osci, but I will test it with a friends.

Thanks Chris

themroc:
But the original Makey has a Mouseclick. Is it possible to get a Mouseclick send over USBKeyboard? Do I have to change some report descriptors (like http://www.instructables.com/id/USB-Wii-Classic-Controller/step13/Bonus-Keyboard-and-Mouse/) and adapt the code or is their possibly another trick?

Yes, V-USB can do mouse-ish stuff... but I have not played with this... you may wish to look into the work done by Frank Zhao (now with Adafruit) on the USnoobie: USnooBie or even some of the Trinket or Digispark examples. Also, V-USB has an entire listing of reference projects: http://www.obdev.at/products/vusb/prjobdev.html

Good luck!

Ray

mrburnette:
There is a library for that from one of the forum members:
Project Log : Arduino USB - ProjectLogArduinoUSB

I have a thread using the library here:
Project Log : Arduino USB - ProjectLogArduinoUSB

Hi Ray,

I also play with this project.

The Arduino IDE that works with rancidbacon project is Arduino-018
and in Windows operating system.

Hi,

I've tried to compile the examples with Arduino IDE 1.8.5 - but I get a lot of error message in usbdrv.h

Some ideas?

BR

Hartmut

hwhardsoft:
Hi,

I've tried to compile the examples with Arduino IDE 1.8.5 - but I get a lot of error message in usbdrv.h

Some ideas?

BR

Hartmut

http://forum.arduino.cc/index.php?topic=391253.0#subject_2694938