V-USB Port to Arduino..

ok, after some digging, i installed Win-AVR (yawn)... even now 6 hours later, still not really that much further than i was 6 hours ago!

So, i decided to look for someway of getting Arduino to handle it instead of WinAVR, anyway i found a guy who did it, and the code COMPILES amazingly
even though he made it 2 years ago!

Problem 1. sort of fixed.
Problem 2. What i'm trying to do is get the Attiny85 to work with it so i "select" Attiny85, it's a modified board file i did sometime ago and it works nicely,
now then if only I could figure out how to get it to play nicely and compile code in Arduino!

If you extract both zips, attiny to the hardware and the Port of VUSB to the Library folder and run the example, it compiles just fine undero uno, but
when i select my attiny85 it fails to compile :frowning:

um, any clues?

If we/you someone :slight_smile: can fix it, it would mean the ability to turn an Attiny85 into a USB HID device with Arduino! who would not find that useful!

Errors

#include "UsbKeyboard.h"

#define BUTTON_PIN 12

// If the timer isr is corrected
// to not take so long change this to 0.
#define BYPASS_TIMER_ISR 1

void setup() {
  pinMode(BUTTON_PIN, INPUT);
  digitalWrite(BUTTON_PIN, HIGH);
  
#if BYPASS_TIMER_ISR
  // disable timer 0 overflow interrupt (used for millis)
  TIMSK0&=!(1<<TOIE0); // ++
#endif
}

#if BYPASS_TIMER_ISR
void delayMs(unsigned int ms) {
   /*
  */ 
  for (int i = 0; i < ms; i++) {
    delayMicroseconds(1000);
  }
}
#endif

void loop() {
  
  UsbKeyboard.update();

  digitalWrite(13, !digitalRead(13));

  if (digitalRead(BUTTON_PIN) == 0) {
    
    //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
    
    UsbKeyboard.sendKeyStroke(KEY_H);
    UsbKeyboard.sendKeyStroke(KEY_E);
    UsbKeyboard.sendKeyStroke(KEY_L);
    UsbKeyboard.sendKeyStroke(KEY_L);
    UsbKeyboard.sendKeyStroke(KEY_O);

    UsbKeyboard.sendKeyStroke(KEY_SPACE);

    UsbKeyboard.sendKeyStroke(KEY_W);
    UsbKeyboard.sendKeyStroke(KEY_O);
    UsbKeyboard.sendKeyStroke(KEY_R);
    UsbKeyboard.sendKeyStroke(KEY_L);
    UsbKeyboard.sendKeyStroke(KEY_D);
    //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);

    UsbKeyboard.sendKeyStroke(KEY_ENTER);
#if BYPASS_TIMER_ISR  // check if timer isr fixed.
    delayMs(20);
#else
    delay(20);
#endif
    
   }

}

Errors.

In file included from UsbKeyboardDemo1.cpp:1:
C:\Arduino\arduino-1.0.1\libraries\UsbKeyboard/UsbKeyboard.h: In constructor 'UsbKeyboardDevice::UsbKeyboardDevice()':
C:\Arduino\arduino-1.0.1\libraries\UsbKeyboard/UsbKeyboard.h:131: error: 'PORTD' was not declared in this scope
C:\Arduino\arduino-1.0.1\libraries\UsbKeyboard/UsbKeyboard.h:132: error: 'DDRD' was not declared in this scope
UsbKeyboardDemo1.cpp: In function 'void setup()':
UsbKeyboardDemo1.pde:-1: error: 'TIMSK0' was not declared in this scope

Both the Libraries for VSB and the hardware mod for the Attiny85 i've attached here, everyone and their dog should be able
to compile and run this, now for the attiny85 :slight_smile:

attinyownmods hardware folder.zip (2.4 KB)

vusb-for-arduino-005 Libraries.zip (347 KB)

http://code.google.com/p/vusb-for-arduino/

where the port is, and it works when i select "uno" - just does not work with my attiny85 :((

Does the 'tiny have those ports ?

I should hope so, it was meant for the ATTiny85...

Which 'it' are you referring to ?

There is no port d on an 85... according to tiny core_pins.h port b though, 6 pins and b5 is reset. So you 'might' have issues with addressing port d in your code....
Ya Think?

I never coded it.....

I just want to know how to fix it....

But apparently

it was meant for the ATTiny85...

http://www.google.com.au/search?site=&source=hp&ei=YpuaUfHkC4ujiAe2tYDIBQ&q=vusb+attiny85&oq=vusb+attiny&gs_l=mobile-gws-hp.1.0.0j0i10l3j0i22i30.3330.7931.0.9902.13.11.0.2.2.0.402.3248.2-1j8j1.10.0...0.0...1c.1.14.mobile-gws-hp.lNXX66eZb9I

explain that then....

So, V-USB was designed for use with the ATTiny85, but the errors are about the use of ports by UsbKeyboard.h

In file included from UsbKeyboardDemo1.cpp:1:
C:\Arduino\arduino-1.0.1\libraries\UsbKeyboard/UsbKeyboard.h: In constructor 'UsbKeyboardDevice::UsbKeyboardDevice()':
C:\Arduino\arduino-1.0.1\libraries\UsbKeyboard/UsbKeyboard.h:131: error: 'PORTD' was not declared in this scope
C:\Arduino\arduino-1.0.1\libraries\UsbKeyboard/UsbKeyboard.h:132: error: 'DDRD' was not declared in this scope
UsbKeyboardDemo1.cpp: In function 'void setup()':
UsbKeyboardDemo1.pde:-1: error: 'TIMSK0' was not declared in this scope

Recommended reading:
http://forum.arduino.cc/index.php?topic=8571.10;wap2

I've built several tiny85 VUSB projects as well as 328P and Nano versions. The library works great with Arduino fully-supported uC's: i have used it with UNO, MiniPro @5V, Nano, as well as 5V barebones.

However to program the ATtiny85, I utilize Frank's Zhao AVRProjectIDE:
http://code.google.com/p/avr-project-ide/

After the binary file is created, it can be uploaded with AVRISP or ArduinoISP (actually, the IDE can do the upload, but I prefer the command line.)
avrdude -c arduino -p Attiny85 -P com15 -b 19200 -U flash:w:main.hex -U hfuse:w:0xdd:m -U lfuse:w:0xe1:m

Ray

RancidBaconInterface.jpg

thanks ray, i'll check it out first thing in the morning, not near my desktop right now but if what you said is true, i'd be a very happy chappy :slight_smile:

cheers!

Is there any progress in this area?
I also want to build a project using ATTiny85 and V-USB and run into exactly the same errors as above.
The code compiles and runs ok using my Due, but it won't compile for tiny complaining about missing port D (which I understand, but can't fix as I am unable to understand the UsbKeyboard.h library). I modified the usbconfig.h file, of course, with no luck for now...
Can someone, please, assist?

The Rancid Bacon keyboard.h will not work AS WRITTEN on At tiny.

For the tiny85, follow the Adafruit Trinket schematic or the Digistump Digispark schematic (essentially the same). You can use either firmware with Arduino(with some deviation.)

Here is my build:
http://forum.arduino.cc/index.php?topic=187444.0

Ray