ATTiny85 code

I need some advice on how to get some code into an tiny85. The project is a variant of the 4 key keyboard at

http://blog.flipwork.nl/?x=entry:entry100224-003937

It's a neat project but I can't seem to figure out how to get the code into the 85! I normally use a mac and can't use Atmel Studio, so I put it on the windows box. But now what? I have a hex file for the code and such. But why can't the code just be put into a new sketch in the Arduino IDE? I can use the UNO as an ISP. I do have an USBASP board but unsure how exactly to use it. I have not had to yet, as I just got it.

Can someone please help me out and tell me how to get the code into this little chip? Please?

Is there a place to get a few good tutorials on this Windows version stuff or can I use my mac?

It's so frustrating to not be able to figure it out. I just want a program in the 85 to input a few passwords to save me some typing!

Thanks folks.

Andrew

read this

http://www.ladyada.net/learn/avr/avrdude.html

copy (dont move)

arduino-1.x\hardware\tools\avr\etc\avrdude.conf

to arduino-1.x\hardware\tools\avr\bin

and use your new found skill

that is how I would do it anyway, there are a few other ways

Thank you I'll have a look at that.

Andrew

Ok looked at that tut..looks good. I set it up as it described and shot a prog to my attiny85. Here is what it spit out...

avrdude -c usbasp -p attiny85 -u flash:w:4-Key-Keyboard.hex --- (my input line)

avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e930b

avrdude done. Thank you.

So does that mean it worked or it didn't ? Seems to me like it did, I am not quite set up with my circuit yet to see if it works. So unsure still. You know what I will try a blink or something simple and let you know.

Andrew

it sometimes takes some fiddling

if your using an arduino as an isp use

-c avrisp

also did you compile this software against an attiny core file (like arduino tiny) the pins wont match up

Osgeld, I just took the hex file from the website where it was and then plugged in the USBasp and then plugged separate wires into the breadboard as per a wiring diagram pinout for the tiny85 and the USBasp programmer.

You are right I did what I thuoght was the same command and it worked. Bad jumper maybe? But I got this....

avrdude -c usbasp -p attiny85 -U flash:w:4-Key-Keyboard.hex (MY COMMAND)

avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e930b avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option. avrdude: erasing chip avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: reading input file "4-Key-Keyboard.hex" avrdude: input file 4-Key-Keyboard.hex auto detected as Intel Hex avrdude: writing flash (2396 bytes):

Writing | ################################################## | 100% 1.47s

avrdude: 2396 bytes of flash written avrdude: verifying flash memory against 4-Key-Keyboard.hex: avrdude: load data flash data from input file 4-Key-Keyboard.hex: avrdude: input file 4-Key-Keyboard.hex auto detected as Intel Hex avrdude: input file 4-Key-Keyboard.hex contains 2396 bytes avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.28s

avrdude: verifying ... avrdude: 2396 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you. No AVRDUDE THANKYOU!!! :) :) Looks like success to me. Now I will test the circuit out.

Now to figure out how to modify it and then make a new hex file with my customizations. (i'll be back asking for help) :) 1 step at a time....

Andrew

if it did not upload add

-b 19200

to the end of your command

ya know I almost exclusivity use this as my programming and I still go "man yea ok my bad"

which is one of the reasons arduino is nice, it hides it all from you in a pretty text file (which I guess we could have done, but it takes about as much effort, once you figure out the switches)

also unless you have access to the source its going to be hard to mod, and is it arduino or avr studio? if its arduino we can just make that text file reflect your setup so you just click upload

but I like making people learn the hard way XD

Thanks Osgeld. It seemed to upload fine.

Thanks for your help. Now that it is uploaded, or that I have figured it out, it really isn't what I need. :P But it was a process anyway. I want to push a button and have it send text (my passwords) to the computer. Has anyone seen a good example of this where I could start?

Thanks.

Andrew

Google lists several possible options to investigate... http://petrockblog.wordpress.com/2012/05/19/usb-keyboard-with-arduino-and-v-usb-library-an-example/ http://blog.flipwork.nl/?x=entry:entry081009-142605;comments:1 http://hackaday.com/2012/03/05/usb-dongle-generates-and-enters-your-passwords-so-you-dont-have-to/

Thanks I had seen the bottom two but not the first one. THANKS!!

Andrew

After looking at all the web pages for the same type of thing. I am confused. Some code has timers and clock settings , some don’t , it won’t verify most of it in the Arduio IDE.

Can someone guide me along with even a block diagram, or some code to look at? I can’t get it, but I think if I have some code and a helper I can figure it out.

Maybe there is code out there already done. There is some but it doesn’t seem to fit. The closest I found is this…but I can’t verify and upload it. There are Errors.

#include "UsbKeyboard.h"
 
#define PIN_BUTTON 5 // the button is attached to pin 5
 
int lastState = LOW; // LOW is equivalent to 0
 
void setup() {
  //  button setup
  pinMode(PIN_BUTTON, INPUT);
   digitalWrite(5, HIGH);
 
  // USB setup -----------------
  // Disable timer0 since it can mess with the USB timing. Note that
  // this means some functions such as delay() will no longer work.
  TIMSK0 &= !(1<TOIE0);
  // Clear interrupts while performing time-critical operations
  cli();
 
  // Force re-enumeration so the host will detect us
  usbDeviceDisconnect();
  delayMs(250);
  usbDeviceConnect();
 
  // Set interrupts again
  sei();
}
 
void loop() {
  // update USB device state
  UsbKeyboard.update();
 
  // check, if transition to button-pressed has occured
  if( (digitalRead(PIN_BUTTON) == HIGH) && (lastState==LOW) ) {
    UsbKeyboard.sendKeyStroke(KEY_D, MOD_SHIFT_LEFT);   // if so, send the letters via USB keyboard
    lastState = HIGH; // update the state variable
    delay(10); // simple de-bouncing
  // check, if the button was released
  } else if( (digitalRead(PIN_BUTTON) == LOW) && (lastState==HIGH) ) {
    lastState = LOW; // if so, update the state variable
    delay(10); // simple de-bouncing
  }
 
}
 
// helper method for V-USB library
void delayMs(unsigned int ms) {
  for( int i=0; i<ms; i++ ) {
    delayMicroseconds(1000);
  }
}/code]

I don't know where you got the code from but if you view this http://code.rancidbacon.com/ProjectLogArduinoUSB and download the latest version of the code (link on the above web site) http://code.rancidbacon.com/files/arduinousb/arduinousb_release_004.tar.gz apply the changes at the bottom of the post

Thanks to some pushing from http://hypatia.ca/ I've finally sorted out the issues with Arduino 0018 and the ATmega328p. You want to add this around "usbPoll" and "usbInit" in "usbdrv.h":

ifdef __cplusplus

extern "C"{

endif

...

ifdef __cplusplus

} // extern "C"

endif

And then from http://forums.obdev.at/viewtopic.php?f=8&t=4022 add this to "usbconfig.h":

define USB_INTR_VECTOR INT0_vect

then you can compile the "UsbKeyboardDemo1.pde" in the examples folder and/or the Practical Arduino http://www.practicalarduino.com/projects/virtual-usb-keyboard example code here https://github.com/practicalarduino/VirtualUsbKeyboard/blob/master/VirtualUsbKeyboard.pde All this is for a 328 chip so don't know what problems you will have porting to an 85 but maybe a look here will help http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/