I'm a beginner. My problem is a ~ 6x delay time in the program below.
I use an ATtiny85 on a breadboard with 8Mhz internal clock an an AVRISP mkII programmer.
#include <avr/power.h>
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
pinMode(1, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
What is the reason for so much delay? This program works fine on a Trinket from Adafruit.
Did you set the Tiny's fuses to internal 8MHz, no clock division (CKDIV8)?
If so, I believe you should define F_CPU yourself at the top of the program, to be 8000000.
but the Arduino 1.0.6 has no feature to set the fuses ...
Whats the way? Use a special tool?
THX
Rabis
The Arduino IDE assumes the fuses are set in advance - ATtiny programming with this IDE is kind of a hack so you have to work around it.
You can either set F_CPU to 1000000 (1 million) and hope it matches the MCU defaults, or write the appropriate command for AVRDude. Here's a tutorial (see the "burning fuses" section), but be warned - read carefully about the fuses and how to set them before you attempt anything, because mistakes there can really make your life hard.