Pages: [1]   Go Down
Author Topic: Need to control mutliple LED's with ATtiny 13 :)  (Read 490 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I need to control multiple LED's with the attiny 13! I want to create a led chaser. so it goes in a line etc... here is my code... I want to make it work with a ATtiny. Also can some one tell me what all of the pins are on the attiny 13. such as the reset pin etc and what they do? I really really appreciate it!! smiley-cool


void setup(){
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
}

void loop(){
  digitalWrite(12,HIGH);
  delay(100);
  digitalWrite(12,LOW);
 delay(25);
  digitalWrite(11,HIGH);
  delay(100);
  digitalWrite(11,LOW);
 delay(25);
  digitalWrite(10,HIGH);
  delay(100);
  digitalWrite(10,LOW);
 delay(25);
  digitalWrite(9,HIGH);
  delay(100);
  digitalWrite(9,LOW);
 delay(25);
  digitalWrite(8, HIGH);
  delay(100);
  digitalWrite(8, LOW);
 delay(25);
}
Logged

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure you want to do this ?
You have to study the datasheet, learn how to program it, learn about fuses.
It is a lot more difficult than an Arduino Uno.
The Arduino does not support the ATtiny13, although someone made a compatible core for it.

The Pro Mini is also very small and is a normal Arduino board. But even that one needs an additional usb to serial converter board to be able to upload a sketch.

You should not change the reset pin, keep it only for reset. It is used to program the chip.
The other pins have multiple functions, you can read about them in the datasheet. So you have 8 pins and 3 you can't use (reset,5V,GND). You can use the other 5 for the leds (leds + resistors). If you need more pins, you can do charlieplexing or use an shiftout register.
Logged

NSW Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 2327
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I gather you are presently implementing this on an Arduino Uno or similar to test it out.  I hope you have resistors of 220 ohms or more in series with each LED.

That is fine, you will simply have to alter the code to suit the tiny, and use your Arduino as an ISP to program the tiny13.

The reset pin does just what it says - resets the chip if you need to.  You can just tie it to Vcc to prevent it doing anything, the chip resets automatically on power up anyway.  You can disable it in order to use the pin for something else, but if you are going to want to re-program the chip later, that makes it difficult, so it is easier to allow that three of the eight pins are occupied by power and reset connections.

Your code would appear to do the job - more or less.  If you post the code here, you should cut and paste it inside a pair of "code" tags generated by the "hash" symbol button in the "post reply" area here.  You could in fact "modify" your original posting here to do this.

I am puzzled by why you feel the need to introduce a gap between the illumination of the "chasing" LEDs.  If anything it is more conventional to provide the opposite - an overlap time.

As it is, I would be inclined to make you code more concise as:

Code:
void flashLED(byte z) {
  digitalWrite(z,HIGH);
  delay(100);
  digitalWrite(z,LOW);
  delay(25);
}

void setup(){
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
}

void loop(){
  flashLED (12);
  flashLED (10);
  flashLED (10);
  flashLED (9);
  flashLED (8);
}
Logged

Pages: [1]   Go Up
Jump to: