Go Down

Topic: Re: Programming Help (Read 1 time) previous topic - next topic

AWOL

Quote
The blink works it's just that i need to know the pins and where to plug them in on this program
Code: [Select]
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 18, 8, 7, 6};
(Though I'm not clear why index zero is a special case)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon

Quote

And pretty much idk if it uploads to program or not


You don't know if you can upload programs or not? Neither do I. Nor anyone else I imagine.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

artixalpha

well im not sure if it uploads the 8x8 led program because i dont know what pins to plug in and i dont know how to declar varibles :S

Msquare

Stop. Just a moment.

When people here write "Do you know how to upload a program (or sketch, same thing)", the issue is NOT with this particular program. The issue is that if you do not know if you have uploaded a program AT ALL, then there is no point in discussing the pin assigments.

I can tell you, so far noone has looked at your program/sketch, because if you give the impression nothing gets uploaded into your Arduino.

Here I give you two programs. One is the standard LED blinky:
Code: [Select]
void setup() {               
  pinMode(13, OUTPUT);     
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);                // wait
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);                // wait  ...
}

the other slightly modified so it "beats like a heart".
Code: [Select]
void setup() {               
  pinMode(13, OUTPUT);     
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(40);                // wait
  digitalWrite(13, LOW);    // set the LED off
  delay(60);                // wait  ...
  digitalWrite(13, HIGH);   //    ... and so on
  delay(150);             
  digitalWrite(13, LOW);   
  delay(1234);             
}

Totally simple. You need to demonstrate to your self that both programs can be alternately loaded into your arduino and the LED blinky changes accordingly. (You can do this several times, it will not wear out your Arduino and you do not need to "clear" anything between attempts) If you know this and it works, the I appologize for telling you something you know, but that is not the impression I get from this thread. In particualar you "clearing the EPROM" activity shows you are "barking up the wrong tree". It is useless but harmless and has no bearing on getting programs to work.

artixalpha

Ok that works whta i mean is that the 8x8 led program is not working?

artixalpha

also i've tried other ones too

Msquare

If you have a faulty program one of two (and a half), scenarios happen:

(1) The program will not compile - it gives errors in the bottom IDE half, and it therefore will not attempt to upload it.

(2) The program compiles, uploads, but fails to produce the expected outcome. It defenitly will execute (the Arduino can never be "halted", it will run doing something always, even if it just is running a loop)

(2b) Program compiles, but because of a hardware error, or because the wrong serial port or board has been specified it fails to upload.

So which of above is what you mean when you say: "8x8 led program is not working"  (Again, painfully slow explanation, because you leave the impression nothing has worked for you so far...)

Nick Gammon


well im not sure if it uploads the 8x8 led program because i dont know what pins to plug in  ...


How can you not be sure? Does it say "Done uploading." or not? Are there are any error messages in red? Does your uploading technique work with other sketches?

If it hasn't uploaded there is no point debugging the sketch, you have to sort out how to upload any sketch. If it is in fact uploaded you need to be sure it has. None of this "oh, I'm not sure" nonsense.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

artixalpha

this is the code:
Code: [Select]
[quote]
#include <FrequencyTimer2.h>
#include [color=#006699]"font.h"[/color]
#include [color=#006699]"figuras.h"[/color]

[color=#CC6600]byte[/color] col = 0;
[color=#CC6600]byte[/color] leds[8][8];

[color=#7E7E7E]// Pines conectados al Arduino (-1 es un fantasma para que empience en la posicion 1)[/color]
[color=#CC6600]int[/color] pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 18, 8, 7, 6};

[color=#7E7E7E]// Columnas de leds = Pines de la matriz[/color]
[color=#CC6600]int[/color] cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

[color=#7E7E7E]// Filas de leds = Pines de la matriz[/color]
[color=#CC6600]int[/color] rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

[color=#CC6600]const[/color] [color=#CC6600]int[/color] numPatterns = 22;
[color=#CC6600]byte[/color] patterns[numPatterns][8][8] = {
  D,A,V,G,E,E,K,PUNTO,C,O,M,SPACE,CARITA,SPACE,Bike,SPACE,Alto,SPACE,FlechaIzq,SPACE
};

[color=#CC6600]int[/color] pattern = 0;

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
   [color=#7E7E7E]// Todos los pines como salidas[/color]
   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 1; i <= 19; i++) {
     [color=#CC6600]pinMode[/color](pins[i], [color=#006699]OUTPUT[/color]);
   }

   [color=#7E7E7E]// Pines en bajo[/color]
   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 1; i <= 8; i++) {
     [color=#CC6600]digitalWrite[/color](cols[i + 1], [color=#006699]LOW[/color]);
   }

   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 1; i <= 8; i++) {
     [color=#CC6600]digitalWrite[/color](rows[i + 1], [color=#006699]LOW[/color]);
   }

   clearLeds();

   [color=#7E7E7E]// Turn off toggling of pin 11[/color]
   FrequencyTimer2::disable();
   [color=#7E7E7E]// Set refresh rate (interrupt timeout period)[/color]
   FrequencyTimer2::setPeriod(2000);
   [color=#7E7E7E]// Set interrupt routine to be called[/color]
   FrequencyTimer2::setOnOverflow([color=#CC6600]display[/color]);

   setPattern(pattern);
}

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
     pattern = ++pattern % numPatterns;
     slidePattern(pattern, 100);
}

[color=#CC6600]void[/color] clearLeds() {
   [color=#7E7E7E]// Limpiar Display[/color]
   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 0; i < 8; i++) {
     [color=#CC6600]for[/color] ([color=#CC6600]int[/color] j = 0; j < 8; j++) {
       leds[i][j] = 0;
     }
   }
}

[color=#CC6600]void[/color] setPattern([color=#CC6600]int[/color] pattern) {
   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 0; i < 8; i++) {
     [color=#CC6600]for[/color] ([color=#CC6600]int[/color] j = 0; j < 8; j++) {
       leds[i][j] = patterns[pattern][i][j];
     }
   }
}

[color=#CC6600]void[/color] slidePattern([color=#CC6600]int[/color] pattern, [color=#CC6600]int[/color] del) {
   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] l = 0; l < 8; l++) {
     [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 0; i < 7; i++) {
       [color=#CC6600]for[/color] ([color=#CC6600]int[/color] j = 0; j < 8; j++) {
         leds[j][i] = leds[j][i+1];
       }
     }
     [color=#CC6600]for[/color] ([color=#CC6600]int[/color] j = 0; j < 8; j++) {
       leds[j][7] = patterns[pattern][j][0 + l];
     }
     [color=#CC6600]delay[/color](del);
   }
}

[color=#7E7E7E]// Rutina de interrupciones[/color]
[color=#CC6600]void[/color] [color=#CC6600]display[/color]() {
   [color=#CC6600]digitalWrite[/color](cols[col], [color=#006699]LOW[/color]);  [color=#7E7E7E]// Turn whole previous column off[/color]
   col++;
   [color=#CC6600]if[/color] (col == 8) {
     col = 0;
   }
   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] row = 0; row < 8; row++) {
     [color=#CC6600]if[/color] (leds[col][7 - row] == 1) {
       [color=#CC6600]digitalWrite[/color](rows[row], [color=#006699]LOW[/color]);  [color=#7E7E7E]// Turn on this led[/color]
     }
     [color=#CC6600]else[/color] {
       [color=#CC6600]digitalWrite[/color](rows[row], [color=#006699]HIGH[/color]); [color=#7E7E7E]// Turn off this led[/color]
     }
   }
   [color=#CC6600]digitalWrite[/color](cols[col], [color=#006699]HIGH[/color]); [color=#7E7E7E]// Turn whole column on at once (for equal lighting times)[/color]
}

[/quote]



This is the error i do not know how to delcare values
Code: [Select]

_8x8.ino: In function 'void setup()':
_8x8:42: error: 'FrequencyTimer2' has not been declared
_8x8:44: error: 'FrequencyTimer2' has not been declared
_8x8:46: error: 'FrequencyTimer2' has not been declared

Nick Gammon

This is not code:

Code: [Select]

[quote]
#include <FrequencyTimer2.h>
#include [color=#006699]"font.h"[/color]
#include [color=#006699]"figuras.h"[/color]

[color=#CC6600]byte[/color] col = 0;
[color=#CC6600]byte[/color] leds[8][8];


Don't use "copy for forum" just copy and paste the code, inside code tags.

How to use this forum
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

artixalpha

Code: [Select]
#include <FrequencyTimer2.h>
#include "font.h"
#include "figuras.h"

byte col = 0;
byte leds[8][8];

// Pines conectados al Arduino (-1 es un fantasma para que empience en la posicion 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 18, 8, 7, 6};

// Columnas de leds = Pines de la matriz
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// Filas de leds = Pines de la matriz
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

const int numPatterns = 22;
byte patterns[numPatterns][8][8] = {
  D,A,V,G,E,E,K,PUNTO,C,O,M,SPACE,CARITA,SPACE,Bike,SPACE,Alto,SPACE,FlechaIzq,SPACE
};

int pattern = 0;

void setup() {
   // Todos los pines como salidas
   for (int i = 1; i <= 19; i++) {
     pinMode(pins[i], OUTPUT);
   }

   // Pines en bajo
   for (int i = 1; i <= 8; i++) {
     digitalWrite(cols[i + 1], LOW);
   }

   for (int i = 1; i <= 8; i++) {
     digitalWrite(rows[i + 1], LOW);
   }

   clearLeds();

   // 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(pattern);
}

void loop() {
     pattern = ++pattern % numPatterns;
     slidePattern(pattern, 100);
}

void clearLeds() {
   // Limpiar Display
   for (int i = 0; i < 8; i++) {
     for (int j = 0; j < 8; j++) {
       leds[i][j] = 0;
     }
   }
}

void setPattern(int pattern) {
   for (int i = 0; i < 8; i++) {
     for (int j = 0; j < 8; j++) {
       leds[i][j] = patterns[pattern][i][j];
     }
   }
}

void slidePattern(int pattern, int del) {
   for (int l = 0; l < 8; l++) {
     for (int i = 0; i < 7; i++) {
       for (int j = 0; j < 8; j++) {
         leds[j][i] = leds[j][i+1];
       }
     }
     for (int j = 0; j < 8; j++) {
       leds[j][7] = patterns[pattern][j][0 + l];
     }
     delay(del);
   }
}

// Rutina de interrupciones
void display() {
   digitalWrite(cols[col], LOW);  // Turn whole previous column off
   col++;
   if (col == 8) {
     col = 0;
   }
   for (int row = 0; row < 8; row++) {
     if (leds[col][7 - row] == 1) {
       digitalWrite(rows[row], LOW);  // Turn on this led
     }
     else {
       digitalWrite(rows[row], HIGH); // Turn off this led
     }
   }
   digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}


Code: [Select]

_8x8.ino: In function 'void setup()':
_8x8:42: error: 'FrequencyTimer2' has not been declared
_8x8:44: error: 'FrequencyTimer2' has not been declared
_8x8:46: error: 'FrequencyTimer2' has not been declared


Nick Gammon

Have you installed FrequencyTimer2 library?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

artixalpha

I cant find it so no not atm

Msquare

So why are you surprised at the error message
Quote
'FrequencyTimer2' has not been declared

if you have not installed it ?


Go Up