I wasn't aware of the HLT port of the Arduino libraries (thanks for that!) I downloaded and installed it per the instructions, put an ATtiny85 and some LEDs on a breadboard, and used a USBtinyISP to program it. Worked great, it was a piece of cake!
Need some more details to help you, though. What are you using for a programmer? Please show us your sketch. What do you have connected to the ATtiny85?
I'm using an Arduino Uno in ISP mode as a programmer. At the moment I'm trying to get Blink working, so I just have VCC, GND (5V from the Arduino) and an LED + resistor on Pin 0. I've also tried powering it with a 9V battery via a 5V regulator, and the result is the same. When trying to get my sketch working, I just had the pins connected as described in the comments of my sketch, and power connected as above. Here's my sketch:
The purpose of this sketch is to immediately illuminate LEDs when it detects sound over a
certain threshold. The LEDs will stay on for a fixed time, then fade out. The cycle will start any time a
sound peak is detected, including during a fade.
5/17/11 - The sketch functions as intended on an Arduino Uno.
// User set variables
const int micPin = 2 ; // Input into analog pin 0 (from a mic through an LM358 op-amp circuit.)
const int ledPin = 1 ; // Output to LEDs via pin 11 (through a resistor.)
const int thresholdPin= 4 ; // Input to set threshold via a potentiometer.
int threshold = 120 ; // Sound level at (or above) which LEDs are illuminated.
const int onTime = 1000 ; // The LEDs will stay at maximum for at least this long.
const int fadeTime = 2635 ; // The LEDs will take this long to fade out.
const int fadeInterval= 30 ; // Time interval between LED brightness increments.
const int fadeAmount = 3 ; // Amount by which to fade, each loop cycle.
// Automatically set variables
int thresholdIn = 0 ; // Potentiometer to set the threshold.
int soundLevel = 0 ; // Current sound level.
unsigned long lightStart = 0 ; // Time the LEDs are lit.
unsigned long fadeStart = 0 ; // Time at which to start fading the LEDs.
unsigned long fadeEnd = 0 ; // Time at which to finish fading the LEDs.
unsigned long timeThen = 0 ; // Time reference for fading
unsigned long timeNow = 0 ; // Time reference for fading
int fadeLight = 0 ; // LED brightness value for fading.
pinMode(micPin, INPUT) ; // Set mic pin as an input.
pinMode(ledPin, OUTPUT) ; // Set led pin as an output.
pinMode(thresholdPin, INPUT) ; // Set threshold pin as an input
//Serial.begin(9600) ; // Serial monitor.
soundLevel = analogRead(micPin); // Read the sound level, store it in an int.
threshold = analogRead(thresholdPin);
// Sound peak
if (soundLevel >= threshold) // If the sound level is equal to or greater than the threshold.
analogWrite(ledPin, 255); // Set the LED output to maximum brightness.
lightStart = millis(); // Store the time in an int.
fadeStart = lightStart + onTime; // Store the time at which to start fading the LEDs.
fadeEnd = fadeStart + fadeTime; // Store the time at which to finish fading the LEDs.
Serial.println(soundLevel); // Send the sound level to the serial monitor.
fadeLight = 0; // Reset the fade brightness int.
// Start to fade
if (millis() >= fadeStart && millis() <= fadeEnd) // If the time the LEDs are supposed to be at max for has elapsed.
timeNow = millis() - timeThen; // Store in an int, the difference in time between the current time and the time the previous cycle ended.
if (timeNow >= fadeInterval) // Check that the amount of time specified by 'fadeInterval' has elapsed (to give a smooth fade).
fadeLight = fadeLight - fadeAmount;// Reduce the LED brightness int by an amount specified by 'fadeAmount')
timeNow = millis(); // Reset timeNow to the current time.
timeThen = millis(); // Reset timeThen to the current time.
analogWrite(ledPin, fadeLight); // Set the LED brightness to the amount now specified by the 'fadeLight' int.
// End fade
if (millis() > fadeEnd) // If the time the LEDs are supposed to lit for has elasped.
analogWrite(ledPin, 0); // Turn the LEDs off.
fadeLight = 0; // Reset the 'fadeLight' int.
Fire up a command prompt and go to whatever directory AVRDude got stuck in (not sure where it goes in windows), then type this
avrdude -C /etc/avrdude.conf -p ATTINY85 -c stk500v1 -b 19200 -P /dev/ttyUSB0 -v
You'll need to replace "/dev/ttyUSB0" with whatever COM port your Arduino is pretending to be at the moment, and "/etc/avrdude.conf" with the path to your avrdude.conf file.
If all goes well it will give you a readout of how happy the attiny is, as well as listing all the fuse bits and such. If it tells you it's an unrecognized chip, you may well have a connection issue.
Alternatively, doublecheck your connections.
Wow, I actually managed to get that to work! Great tip, thank you
I didn't see anything obviously wrong, but I don't understand most of the information it gave me. Shall I copy and paste it here? The connections all seem to be ok, but I don't have another Attiny85 to test until tomorrow.
From the factory, ATtiny85 processors are configured to run from the internal oscillator (8 MHz) divided by 8. So long as you use a 1 MHz board option then you can leave the fuses as they are.
Using the HLT port, there's only one option for the ATtiny85 and Arduino ISP, but I can't tell if it's 1MHz. Do you know what it is?
It's really interesting to learn how simple this process should be. But I'm not sure what I need to do to protect the ATtiny85, so maybe I've damaged it by trying to get my sketch uploaded to it prematurely? In any case I have some more arriving tomorrow, so the fun can continue.