My issue is that the 13pin LED flashes very rapidly. hitting the reset button stops the flash for only as long as the button is pressed. Uploading sketches fails and the programmer "does not respond."
I have read the forums the past few days and discovered many different methods of reset button presses timed precisely or uploading immediately after plugging in USB. but none of these work.
It seems that I have busted the bootloader.
I decided to deal with fixing the chip later, I bought a new UNO today but I wanted to know what exactly could be causing this problem so I didn't do the same mistake.
I am dealing with a two dimensional array with a lot of values. 24*90 byte values.
I had read that it could be possible that an improperly created array or one that is too large, could overwrite the bootloader.
Would anyone take some time to look at my code and let me know if anything is really not right?
Thanks in advance,
Harvey Moon
(This program is adapted from an 8x8 LED matrix. I am running a homemade LED light strip directly from the arduino pins, I would like to swing this LED strip and create a POV type image as it swings. the Angle advances as it swings, and progresses across the 90 values. 24 lights are connected in a row.)
#include <FrequencyTimer2.h>
#define ANGLES 91
#define PASSES 25
byte image[][ANGLES] =
{
{23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23},
{24,24,23,23,24,24,23,23,23,23,23,23,23,23,24,24,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,23,23,23,23,23,23,23,23,23,23,23,23,22,22,23,23,23,22,22,22,22,22,22,22,22,21,21,21,21,21,21,22,22,22,21,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23},
{23,24,24,23,23,23,23,23,23,23,23,23,21,20,17,14,14,11,10,5,4,3,3,3,3,3,3,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,2,2,2,2,2,2,2,2,2,2},
{23,24,24,23,22,20,16,11,9,6,5,5,2,2,2,2,2,2,1,2,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,1},
{23,23,23,22,20,13,9,3,3,3,3,2,2,2,2,1,2,1,1,2,2,1,2,1,1,1,1,1,1,1,2,1,1,2,2,2,2,2,1,2,2,2,3,2,2,2,2,2,3,3,3,2,2,2,2,2,1,1,2,2,2,1,1,1,1,1,2,2,2,2,1,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,1,1,1,1},
{24,23,23,23,23,20,11,4,4,3,2,2,3,2,2,2,1,1,1,1,2,2,2,2,3,2,2,3,4,6,8,9,10,11,13,14,15,15,16,16,16,17,17,17,17,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,16,15,15,15,14,13,12,11,10,9,8,7,7,6,6,5,4,5,4,4,3,3,3,3,2,2,1,1,2,1},
{24,23,24,23,23,22,23,17,10,4,3,3,2,3,2,2,2,2,2,3,2,3,4,5,7,10,13,15,16,17,17,18,18,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,22,21,21,21,21,21,21,21,21,21,21,21,21,21,21,20,20,20,20,20,20,20,19,18,18,17,16,15,14,11,11,9,8,6,5},
{23,24,24,24,24,23,24,24,24,20,13,4,4,3,2,2,2,2,3,3,2,4,5,7,10,14,15,17,17,18,19,19,19,19,20,20,20,20,20,21,20,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,21,21,21,21,21,20,20,21,20,20,20,19,19,19,19,18,18,17},
{24,24,24,23,24,24,23,24,24,24,24,23,24,14,5,5,2,2,2,2,3,2,4,5,6,9,13,16,17,17,18,19,19,19,19,19,20,20,20,20,21,21,21,21,21,21,21,22,22,22,22,22,22,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,21,21,22,21,21,21,21,20,21,21,20,20,20,19,19,19,19,19,19,18},
{24,23,24,24,23,24,24,24,23,24,24,24,24,24,23,23,23,16,5,3,3,2,2,3,3,4,7,12,15,16,17,17,19,19,19,19,20,19,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,21,22,22,21,21,21,21,21,21,21,20,20,20,20,19,19,19,19,19,19,18,18,18,17,17},
{24,24,23,24,23,24,24,24,24,23,24,24,23,23,24,24,23,24,24,24,23,12,1,2,2,2,2,5,15,16,16,16,16,10,9,9,8,8,8,7,5,5,4,4,4,3,4,4,5,7,9,10,13,16,18,19,19,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,20,20,20,20,19,19,19,18,18,18,18,17,17,17,17,16,16,16},
{24,23,23,23,23,23,24,24,24,24,23,24,23,24,23,23,24,24,24,23,24,24,23,23,14,3,2,2,3,16,17,16,16,15,16,15,13,8,10,0,10,6,2,2,6,3,0,17,4,13,10,11,13,14,16,19,20,20,20,19,18,16,15,13,11,9,7,8,5,5,5,5,6,8,11,14,16,17,17,17,17,17,16,16,16,15,15,15,14,13},
{23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,23,24,23,23,24,15,16,15,14,10,4,18,18,19,19,19,19,18,18,18,17,17,17,18,17,17,16,16,16,16,16,15,15,16,17,19,21,21,20,19,17,14,12,12,15,6,12,11,15,6,1,0,0,9,13,14,13,10,5,6,6,8,15,15,15,15,14,12,8,3,2},
{23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,23,24,23,23,24,23,23,23,23,18,18,18,16,12,17,18,19,19,20,20,21,20,21,21,21,20,20,20,20,20,20,20,19,18,18,18,18,20,20,20,18,17,16,15,15,15,15,15,16,15,15,15,13,11,13,13,11,9,9,9,13,13,12,12,14,15,14,5,2,2,2,2,2},
{23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,23,23,23,24,23,25,19,18,18,15,17,18,18,19,20,20,21,21,21,21,21,21,21,21,20,18,17,18,18,20,20,20,20,19,17,16,15,14,16,17,18,19,19,18,18,18,17,18,17,16,16,16,16,16,16,16,15,16,6,3,3,5,6,23,23,23,23},
{2,11,15,18,23,23,23,23,23,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,17,19,15,16,17,18,18,19,20,20,20,21,20,20,20,19,19,18,14,12,9,16,16,17,16,15,14,14,15,16,15,18,19,20,19,19,19,19,19,19,18,18,17,17,16,16,16,16,7,12,14,14,16,25,23,23,23,23,23},
{16,5,5,13,14,15,24,22,22,23,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,16,16,17,17,18,19,19,19,19,18,17,18,17,17,16,16,17,17,15,15,16,14,14,15,16,17,18,18,19,19,18,19,18,17,17,17,16,15,15,15,14,11,12,15,15,24,22,22,22,22,23,23,23,23,23},
{16,16,16,15,10,11,14,15,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,15,16,16,17,17,18,18,17,15,11,6,11,11,12,13,14,15,15,15,15,16,17,15,15,14,15,15,16,17,17,16,16,15,15,15,14,14,11,15,15,23,22,22,22,22,22,22,23,22,22,23,23,23,23},
{17,18,17,16,15,15,11,15,15,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,10,15,16,16,16,16,17,18,18,18,17,16,16,17,16,16,16,16,15,14,14,14,15,14,15,15,15,15,15,14,14,14,12,21,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23},
{19,19,18,17,16,15,15,14,24,22,22,22,22,22,22,22,22,22,22,23,22,23,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,16,15,14,15,15,15,16,16,17,17,18,18,17,16,16,16,16,16,15,15,15,14,14,14,14,14,14,14,11,22,21,21,21,22,22,22,22,22,22,22,22,22,22,23,22,23,23,23,23,23,23},
{19,19,19,18,17,16,16,15,14,12,21,22,21,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,19,13,17,17,17,16,14,12,13,13,15,15,16,16,16,17,16,16,16,15,13,12,12,12,12,12,12,13,15,21,21,22,21,21,21,22,22,22,22,22,22,22,22,23,22,23,23,23,23,23,23,23,23},
{18,19,19,18,17,16,15,15,14,14,13,21,22,22,21,21,22,22,22,22,22,22,22,22,22,23,23,22,23,22,23,23,22,22,23,23,23,24,17,17,18,18,17,17,16,15,13,10,10,10,11,11,12,12,12,11,9,9,10,10,12,13,14,15,15,21,21,21,21,21,21,22,22,22,22,22,22,23,23,22,23,23,23,23,23,23,23,23,23,23},
{16,16,15,15,14,15,15,15,15,14,13,24,21,21,21,21,21,21,22,22,22,23,22,22,22,22,22,23,22,22,22,22,23,23,23,24,23,23,24,18,18,18,18,18,18,17,16,16,15,15,15,14,13,12,12,13,12,13,14,15,15,15,15,15,13,22,21,21,21,21,21,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23},
{16,17,13,2,13,16,15,14,13,13,12,14,15,21,21,21,21,21,21,22,21,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,23,24,16,17,18,18,18,18,17,16,16,16,16,15,15,15,15,15,16,16,16,16,16,15,15,22,22,22,22,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23}
};
byte col = 0;
byte leds[24];
int angle = 0;
int passCount = 0;
int pins[12]= {
-1, 10,9,8,7,6,5,4,2,3,12,11};
int cols[8] = {10,9,8,7,6,5,4,3};
int rows[3] = {2,12,11};
void setup() {
// Serial.begin(38400);
// sets the pins as output
for (int i = 1; i <= 12; i++) {
pinMode(pins[i], OUTPUT);
}
// set up cols and rows
for (int i = 1; i <= 8; i++) {
digitalWrite(cols[i - 1], LOW);
}
for (int i = 1; i <= 8; i++) {
digitalWrite(rows[i - 1], LOW);
}
// Turn off toggling of pin 11
FrequencyTimer2::disable();
// Set refresh rate (interrupt timeout period)
FrequencyTimer2::setPeriod(2000);
// Set interrupt routine to be called
FrequencyTimer2::setOnOverflow(display);
setPattern();
}
void setPattern() {
for (int j = 0; j < 24; j++) {
leds[j] = image[j][angle];
//Serial.println(leds[j],DEC);
}
// Serial.print("angle : ");
// Serial.println(angle);
//Serial.print("passCount : ");
// Serial.println(passCount);
}
void loop() {
angle++;
if(angle == ANGLES){
angle = 0;
passCount++;
if(passCount==PASSES){
passCount = -1;
}
}
setPattern();
delay(250);
}
void display() {
digitalWrite(cols[col], LOW); // Turn whole previous column off
col++;
if (col == 8) {
col = 0;
}
if(leds[col]==passCount){
digitalWrite(rows[0], LOW);
}
else{
digitalWrite( rows[0], HIGH);
}
if(leds[col+8]== passCount){
digitalWrite(rows[1], LOW);
// Serial.println(col+8);
}
else{
digitalWrite( rows[1], HIGH);
}
if(leds[col+16]== passCount){
digitalWrite(rows[2], LOW);
}
else{
digitalWrite( rows[2], HIGH);
}
digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}