Help with attiny 85

I'm going through this tutorial here:

http://hlt.media.mit.edu/?p=1695

Using an UNO running IDE 1.0 All looks well but the attiny board isn't showing up.

I went through this process:

http://www.youtube.com/watch?v=30rPt802n1k

But couldn't get the blink sketch to even compile. After it didn't work I deleted the "hardware" file and tried to start over but still no joy.

Any input?

Hi,

If the board isn't showing up in your list then you're not going to get to program your ATtiny until that's sorted.

The IDE needs to be restarted for it to discover the files as it starts up - is there a chance you had an instance of the IDE still running when you installed the support files?

Cheers ! Geoff

Two things I can think of, first the version of the tiny 'core' your using may not support 1.0, so give this one a try; http://code.google.com/p/arduino-tiny/

And second, make sure you do not have the IDE running when you unzip the core into the hardware directory. Only after it has been unzipped should you start the IDE

Thanks guys! I'll bet I had the IDE running when I unzipped the files. I'll give it a go. One question though... even though I deleted the original "hardware" folder from the first install the "ArduinoISP" sketch is still showing up in the examples folder. Will a re-install sort this out?

I don’t think you need to do anything as drastic as a re-install, unless you think you deleted too much.

The ArduinoISP sketch isn’t in the ATTiny hardware directory (it’s a standard example in the IDE) so don’t be concerned it’s still there after removing the ATTiny stuff.

Cheers ! Geoff

I tried re-loading it a couple of times without success but the file posted by wanderson (Thanks) seems to work and gives A BUNCH of confusing options! I went through the tutorial in the first link using “Arduino as ISP” chosen from the tools-programmer menu. It is communicating with the board but I get an “out of synch” error.

Oh well, I consider it some kind of progress. There must be something I’m overlooking. I have no idea what chip to pick from the menu. Mine are just ATTINY85 20PU.

I am excited about pulling this off and making gadgets that work sans Arduino!

Thanks again for the help!

hoff70: There must be something I'm overlooking. I have no idea what chip to pick from the menu. Mine are just ATTINY85 20PU.

Hi,

Select ATtiny85 @ 8HMz (internal oscillator, BOD disabled) as the board, select "Arduino as ISP" as the Programmer, then remember to choose the "burn bootloader" and do that just the once to set the internal fuses on the ATtiny85.

After that, your -20PU's will use their internal clock to run at 8MHz and all should be well...

Cheers ! Geoff

Thanks again! I did what you suggested and now I get a "not in sync" error. Even though it's not working I'm encouraged. I'll probably try another chip out and see how it goes. The bootloader part seemed to work because the ATiny shows up on the bottom portion of the IDE on the proper port. I hope I have it wired correctly. I'm going by the tutorials which all seem show the same wiring.

One thing I did notice is that the sketch that I'm trying to write to the tiny (Blink, pin 3) seems to write to the Arduino.

Have you hooked a capacitor up to the reset pin on the Uno?

I have a 10uF cap between reset and ground with the polarity correct.

When I upload it compiles-loads and I get some flashing of the RX LED followed by a longer than usual pause of no blinking then the error.

I'm just loading the blink sketch without first loading the Arduino as ISP sketch first as I did before with the first tutorial.

Feels like I'm pretty close...

It sounds like you're close.

You need to have loaded the ArduinoISP sketch onto the Uno first (ie without the cap installed) then, after you connect your ATTiny and the cap, when you upload the blinky sketch it will be passed through to the ATTiny...but you do need to have ArduinoISP loaded first.

If you're using the unchanged IDE 1.0 ArduinoISP from the examples folder it had a line that caused issues on my Uno (and I think all?)

void setup() {
  Serial.begin(19200);
...

Changing that to Serial.begin(9600);I think was necessary if I remember correctly. Certainly that's a difference between the version I run routinely, and the standard example sketch. I may have made more changes but I don't appear to have commented the changes at the time.

Hope this helps, Geoff

There are some issues in the 1.00 version of the ArduinoISP sketch .

Codung Badly has made an updated sketch here (Reply #39)

Thanks for all the AWESOME help!

:slight_smile:

I did it! Just few details that had me tripped up. This is really pretty amazing stuff. Sure, I’m just blinking a light but programming a little IC that runs without any other assistance just amazes the sh!t out of me 8)

I picked up a proto shield and some odds and ends from RS and I’m thinking about making a dedicated 85 programmer. Any input on this? Input on some 85 projects?

I’m shooting for a 328 programmer for some permanent projects.

Thanks again!

Here’s a sketch that works with the 85 and an Sr04 sensor:

//"Arduino Garage Tennis Ball."  A distance sensor with LED Stoplights for people with multiple vehicles going into a limited space.

const int triggerPin = 0;
const int echoPin = 1;
int redPin=2;
int yellowPin=3;
int greenPin=4;
long duration;
long distance;

void setup(){
  pinMode (13, OUTPUT);
  pinMode (12, OUTPUT);
  pinMode (11, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  int stopDistance=6;//object distance in inches from sensor that you want to trigger the Red LED.
  int warnDistance=60;//object distance in inches from sensor that you want to trigger the Yellow LED.
  pinMode(triggerPin, OUTPUT);
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(triggerPin, LOW);
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);
  distance = duration / 72 / 2;//determines distance in inches of object from sensor by microseconds to inches formula.
  if (distance >= warnDistance){
    digitalWrite (redPin, LOW);
    digitalWrite (yellowPin, LOW);
    digitalWrite (greenPin, HIGH);
  }
  else if((distance>stopDistance) && (distance<warnDistance)){
    digitalWrite (redPin, LOW);
    digitalWrite (yellowPin, HIGH);
    digitalWrite (greenPin, LOW);
  }
  else{
    digitalWrite (redPin, HIGH);
    digitalWrite (yellowPin, LOW);
    digitalWrite (greenPin, LOW);
  }
  Serial.println (distance);
}

It uses all of the 85’s pins and it’s a little wonky but it’s close. All it does is light 3 LEDs based on distance from the sensor. I think the code is screwy but the hardware seems to be doing it’s part!

Look ma, no Arduino:

hoff70:
I did it!

Excellent! Congratulations!

hoff70:
I picked up a proto shield and some odds and ends from RS and I’m thinking about making a dedicated 85 programmer. Any input on this?

Include 220 ohm (or higher; 1K is typically used) series resistors on MISO, MOSI, and SCK. A problem like this one could create a short-circuit through the two processors and damage them. The resistors keep the current flow in a safe range, they are dirt cheap (compared to everything else involved), and they cause no problems when programming.

Input on some 85 projects?

ATtiny85V processors and batteries go very well together.

Thanks again! I'll be sure to include the resistors. Have to check the pinout...

Just to clarify, I'll be placing the resistors between the Arduino pins and the 85? In place of the jumper wires?

I have a big resistor assortment that should come in handy!

The iron is warming now :sweat_smile:

Great news! :D

hoff70: I picked up a proto shield and some odds and ends from RS and I'm thinking about making a dedicated 85 programmer. Any input on this? Input on some 85 projects? ... I'm shooting for a 328 programmer for some permanent projects.

I've made a protoshield with a socket on it for programming the ATtiny85. There are a lot of examples online and it was very easy & rewarding to do. It's got the 3 LEDs for activity/error/pulse on it.

For the ATmega328 programming, I find it easier to include a set of FTDI headers (6 in a row) and program the ATmega in place using an FTDI adapter (you won't regret buying one of those) on the project board itself. Bootloading the ATmega328 is a simple process on a breadboard, so you can batch write to them when you buy the bare ones and keep them on the shelf until needed.

Nick Gammon's website has a stack of great tips for doing this. I don't know how many times I open that page for a brain-refresh :)

Cheers ! Geoff

hoff70: Just to clarify, I'll be placing the resistors between the Arduino pins and the 85? In place of the jumper wires?

Exactly.

This may or may not work:

The funk behind the curtain:

I think I would have been better off orienting the 85 the other way to keep wires from crossing. Maybe it won't be a problem. I ganged the LED's to ground with a single resistor which is something I've been doing, May not be such a good idea though...

Yea, it was fun to make no matter the outcome :)

This is my first "hard wired" arduino project. I'll post back about how it works.

Still a few hiccups...

When I hit the reset button on the board I get a light sequence from the LEDs installed on the protoshield. Each flash quickly in turn so something seems to be working.

I went through the same sequence as before and now I get a red blink when uploading and some synch errors. I got some of the "nuisance" errors before but it doesn't seem to be working.

I was trying a different chip this time though and I had tried to do the bootload on it without success before and it doesn't seem to be working now either.

I may try loading a sketch onto the chip I had working earlier and see how it goes.

I did the usual continuity checks, etc. plus triple, triple checked the wiring and all seems OK. I have a sneaky feeling I'm forgetting to do something that I did right before but d@mned if I can figure out what it is :roll_eyes:

Seems like I used the sketch from post 39 : http://arduino.cc/forum/index.php/topic,108797.30.html

Strange, I went back to the breadboard with my original setup and I can't duplicate earlier success... I'm getting the "avrdude PAGEL BS2" and "protocol error" errors after burn bootloader and uploading the blink sketch which I believe are just nuisance errors but no blink...

One thing I'm not sure about is if the capacitor is needed for "burn bootloader"? And will it damage the chip if I burn it more than once. Earlier I managed to load several different sketches onto the 85 without any problems but after putting this shield together things are a little wonky...

I suppose I need to troubleshoot the pins on the arduino which are used to program the 85. I may have damaged them. I figure if I can get pins 11, 12 and 13 to blink an LED then all is well on that front.

Thanks again for all the help. It's just a little frustrating that I can't get it to work again...

Well, the pins seem to be working. I can still blink LEDs on 11, 12 and 13.

Triple checked the wiring again:

Pin 10 on Arduino to pin 1 on 85 :blush:

All is well again... Looks like my oscillator or something is screwy because it blinks every 7 seconds or so. I'm pretty sure I loaded 8mhz but I was pretty sure I had it wired correctly too...

Hi,

It is frustrating when things don't work every time. I empathise.

hoff70: One thing I'm not sure about is if the capacitor is needed for "burn bootloader"? And will it damage the chip if I burn it more than once.

Yes you need that cap for whenever you want to write to the ATtiny - it's to keep the Arduino from resetting and having your sketch upload to the Uno instead. The Burn Bootloader step is just to set the fuses internally to tell the ATtiny to use the clock settings you intend to use. There is no downside to doing this again if you think that step didn't work first pass through.

From my shield, the connections are: Uno D7 - activity LED Uno D8 - error LED Uno D9 - pulse LED Uno D10 - ATtiny85 pin 1 (reset) Uno D11 - ATtiny85 pin 5 Uno D12 - ATtiny85 pin 6 Uno D13 - ATtiny85 pin 7 5V - ATtiny85 pin 8 GND - ATtiny85 pin 4 And that 10uF cap between 5V and the Uno reset.

Sounds like you've got it all setup that way though.

Cheers ! Geoff