Pages: [1]   Go Down
Author Topic: AtTiny85 not working correctly with Charlieplexed 20 LED matrix  (Read 710 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone, I'm working on a project using the AtTiny85 and the arduino as an ISP, I'm kind of stuck and could use some help.

The Project: I have a 4 x 5 charlieplexed LED matrix being controlled by 5 pins, I have the code and tested it with pins (13,12,11,10,9) on my Uno and it works perfectly, the LED's light up scrolling through the message "PARTY TIME" (Soon to be changed to something a little more useful).

The Problem: Despite this code working perfectly for my Arduino Uno, when I change the pins being used to 0,1,2,3,4 for use with the AtTiny85 and upload it, connect the AtTiny85 to the LEDs and add power, it doesn't work properly, nothing happens, I doesn't work as it should. Initially no LEDs turned on and I thought my chip was broken so I uploaded the blink example to test it and the chip is working perfectly fine but just in-case I re-burned the boot-loader for it, tested it out with the blink script, then uploaded my code again. Now one LED turns on and stays on which makes even less sense to me than no LEDs turning on. So right now I'm stumped because its supposed to be scrolling through a message. Again I would like to stress the fact that the code worked perfectly with my arduino uno and the only changes I made before uploading it to the AtTiny85 was changing the pin designations to 0,1,2,3,4 instead of 13,12,11,10,9 so I could use it with the AtTiny85.

Any help would be GREATLY appreciated, Thanks!

I have also added my code below in-case anyone sees something that would make this not work with the AtTiny85

The Code:
Code:
int pins[] = {0,1,2,3,4};
int array[4][5] = { // The "Frame" of the clip that its on
  {1,1,1,1,1},
  {1,1,1,1,1},
  {1,1,1,1,1},
  {1,1,1,1,1}
};

int animation[4][53] = { // The clip that it scrolls through saying "PARTY TIME"
      {0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,1,1,0,1,0,0,0,1,0,0,1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,0,0,0,0},
      {0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,1,1,0,1,1,0,1,1,0,0,1,0,0,0,0,0},
      {0,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0},
      {0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,0,0,0,0}
};

int DelayRate = 1;
int frameRepeat = 1;
void setup() {
reset();
}

void loop(){
  for(int frame = 4; frame < 52; frame ++){ // frame has to intialy equal 4
  for(int i = 0; i < 5; i++){
  for(int j = 0; j < 4; j++){
   array[j][i] = animation[j][i+frame-4];
  }
  }
  for(int i = 0; i < frameRepeat; i++){
   AnimateArray();
  }
  }
}


void AnimateArray() {
for(int anim = 0; anim < 5; anim ++){
 for(int rows = 0; rows < 4; rows++){
  if(array[rows][anim] == 1){
    if(3-rows >= anim){
    pinMode(pins[3-rows+1],OUTPUT);
    digitalWrite(pins[rows+1],LOW);
    }
     else {
    pinMode(pins[3-rows],OUTPUT);
    digitalWrite(pins[rows],LOW);
     }
    pinMode(pins[anim],OUTPUT);
    digitalWrite(pins[anim],HIGH);
     delay(DelayRate);
     reset();
   }   
 } 
}
}

void reset() {
  for(int i = 0; i <= 5; i++){
  pinMode(pins[i],INPUT);
  }
}
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13027
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Make the three arrays byte instead of int.
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3438
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your animation array is taking up 4/5 of your Attiny's memory.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Make the three arrays byte instead of int.
Could you explain what that would change? Can the AtTiny85 not handle an int array?
Quote
Your animation array is taking up 4/5 of your Attiny's memory.
From what I found, the AtTiny85 has a memory of 8Kb (Though I could be wrong), all of this code is about 1.6Kb, but would getting close to maxing the memory make the code not work? Because as I said above this code worked perfectly with the Uno but for some reason it won't work with the AtTiny85.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Make the three arrays byte instead of int.
I did, then uploaded it and it fixed the problem, thanks! I would still like to know why the int array wasn't accepted by the AtTiny85 though, but thanks again!
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3438
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It does accept int arrays. The problem is you are mistaking program memory, which is 8k with SRAM which is 512. Variables are stored in the SRAM, unless you use PROGMEM. Switching to byte arrays cut down the SRAM.
Logged

Pages: [1]   Go Up
Jump to: