2

I started my first try in programming an ATTINY13 with my Arduino 2560.

Everything seemed fine, however when I wanted to run the blink example, my LED did not blink, it keeps lighting.

I am using 5V as input voltage.

I did not change the blink example except for the correct pin number.

All the wiring seems correct, when I change the pin number the LED stays dark, so my program is arriving propperly on the ATTINY.

If I start playing with the delays (delaymicroseconds) I get the LED to become darker.

The documentation of the ATTINY13 (www.atmel.com/images/doc2535.pdf) mentions a maximum clock frequency of 20MHz. When I choose the ATTINY13 from the Arduino IDE board menu it is listed with a 9.6MHz clock.

Could this be a reason? How can I adjust or take care of that?

----------- Edit:

I was starting with the default blink example (delay(1000)).

I played with both, the normal delay and the delayMicroseconds.

The following codes dimmed the LED:

void setup() {
  pinMode(3, OUTPUT);
}

void loop() {
  digitalWrite(3, HIGH);
  delayMicroseconds(10);
  digitalWrite(3, LOW);
  delayMicroseconds(1000);
}

Which makes me believe the LED is blinking very fast. A similar sketch with normal delay does not make the LED dim:

void setup() {
  pinMode(3, OUTPUT);
}

void loop() {
  digitalWrite(3, HIGH);
  delay(1);
  digitalWrite(3, LOW);
  delay(100);
}

And as mentioned with the default blink sketch the LED nothing happens as well.

I also made the delay a ever increasing variable to see if something is happening, no luck. And I have 2 ATTINYs to test, same result for both...

--- Edit2:

Another try:

int led = 3;

void setup() {
  pinMode(led, OUTPUT);
  digitalWrite(led, HIGH);
  delayMicroseconds(100);
  digitalWrite(led, LOW);
}

void loop() {
}

Now I moved switching the LED on and off into the setup function. Strangely enough, by changing the delay between 1000 and 100 micro seconds, the LED gets lighter and darker...

---- Edit 3:

Here is my circuit:

enter image description here

And this is the ATTINY specific code I added to the Arduino IDE:

attiny13.name=ATtiny13 (internal 9.6 MHz clock)
attiny13.bootloader.low_fuses=0x7a
attiny13.bootloader.high_fuses=0xff
attiny13.upload.maximum_size=1024
attiny13.build.mcu=attiny13
attiny13.build.f_cpu=9600000L
attiny13.build.core=arduino:arduino
attiny13.build.variant=tiny8
  • Sounds like the LED is flashing very quickly. Try delaying for a longer time. – geometrikal Aug 7 '14 at 12:08
  • Delay microseconds? That's a very short amount of time... try using delay() in general because that is milliseconds – Anonymous Penguin Aug 7 '14 at 13:32
  • 1
    Possibly the fuse is not set correctly to match the desired oscillator. – mpflaga Aug 7 '14 at 13:58
  • If it is getting lighter and darker in set up then the ATTiny is resetting. What clock source are you using? – geometrikal Aug 7 '14 at 21:39
  • Post your circuit. How have you connected the reset pin? – geometrikal Aug 7 '14 at 21:42
2

The documentation of the ATTINY13 (www.atmel.com/images/doc2535.pdf) mentions a maximum clock frequency of 20MHz. When I choose the ATTINY13 from the Arduino IDE board menu it is listed with a 9.6MHz clock.

Could this be a reason? How can I adjust or take care of that?

I don't think it is the reason, as it is totally fine to underclock your chip. In fact, most Arduino boards are underclocked. In fact, the Arduino Uno's chip can do 20MHz, but it is only ran at 16MHz.

As mentioned in the comments, your oscillator might be off. However, it should still blink. If you're saying changing the pin makes it go dark, then some code is running.

My guess is your delay is way to short. You said you were using delayMicroseconds(). Emphasis on microseconds, not milliseconds. (1 second = 1,000 milliseconds; 1 millisecond = 1,000 microseconds) If you meant to be using milliseconds, it is very possible that you are changing the power to the LED at 1,000 times a second, instead of 1. This would make the LED dimmer than directly to power, but it would still appear lit.

Try this code:

void setup() {
  pinmode(LEDPIN, OUTPUT);
}

void loop() {
  digitalWrite(LEDPIN, HIGH);
  delay(1000);
  digitalWrite(LEDPIN, LOW);
  delay(1000);
}

Of course, replace the LEDPIN with the right value.

  • I added some code an clarification: I used both, delay and delayMicorseconds. – pat Aug 7 '14 at 20:40
  • @pat the first one you delay it for 1.0e-6 seconds, and then 1/1000th of a second. On the second example, you blink it for 1/1000th of a second, and then for 1/10th of a second. Those are way too short. – Anonymous Penguin Aug 7 '14 at 20:43
  • I know, it is to quick to see a blink. But with the first example I see the LED becaome darker (the result of the very fast blink), but not with the second example. – pat Aug 7 '14 at 20:45
  • @pat that is because the LED is only on for 1/1000th of a second. That's not much time! I'd try at least 50 for that delay, although the LED brightness and a few other factors will determine if you can see the LED lighting up. – Anonymous Penguin Aug 7 '14 at 20:52
  • See my new edit, I moved switching the LED into the setup function and the behaviour became even weirder... (thanks for your help btw.) – pat Aug 7 '14 at 21:05
1

Pin 1 is active low reset. Try connecting it to 5V to run the program.

enter image description here

0

I switched to a different ATTINY 13 driver and core definition in the Arduino IDE and this made it work.

Unfortunately by playing around I lost track of the old driver.

I am now using smeezkekitty's core13 which I found here: http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.