Show Posts
|
|
Pages: 1 2 3 [4] 5 6 ... 15
|
|
46
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: 16x8 RGB Matrix Coding Problems
|
on: April 11, 2009, 10:45:41 am
|
OK, now I have re-ordered it and added another function [not important] I get another similar error: #include <Tlc5940.h> #define NUM_TLCS 3 #define NUM_CHNLS 16*NUM_TLCS // The number of LEDs = 3 TLCs * 16 #define WIDTH 16 #define HEIGHT 8
// Column Colour Channels byte redChannels[16] = { 0 ,1 ,2 ,3 ,4 ,5 ,6 ,7, // TLC1: 0 - 7 16,17,18,19,20,21,22,23}; // TLC2:16-23 byte greenChannels[16] = { 8 ,9 ,10,11,12,13,14,15, // TLC1: 8 - 15 24,25,26,27,28,29,30,31}; // TLC2:24-31 byte blueChannels[16] = { 32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47}; // TLC3:32-47 // Row Pins byte rowPins[8] = { 0,1,2,3,4,5,6,7};
int image1R[WIDTH][HEIGHT] = { 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff};
void runImage(byte& colourChannels, int& imageArray){ for(int y=0; y<HEIGHT; y++){ digitalWrite(rowPins[y], HIGH); digitalWrite(rowPins[!y], LOW); for(int i=0; i<WIDTH; i++){ Tlc.set(colourChannels[y], imageArray); } } }
void randomColours(){ for(int y=0; y<HEIGHT; y++){ digitalWrite(rowPins[y], HIGH); digitalWrite(rowPins[!y], LOW); for(int i=0; i<WIDTH; i++){ int randomRed = random(1, 4095); // Generate random number: 1+ so none can ever be off int randomGreen = random(1, 4095); // Generate random number: 1+ so none can ever be off int randomBlue = random(1, 4095); // Generate random number: 1+ so none can ever be off Tlc.set(redChannels, randomRed); Tlc.set(greenChannels, randomRed); Tlc.set(blueChannels, randomRed); delay(100); } } }
void setup(){ randomSeed(analogRead(0)); Tlc.init(); for(int i=0; i<8; i++){ pinMode(rowPins, OUTPUT); } }
void loop(){ runImage(redChannels, image1R); } error: In function 'void runImage(byte&, int&)': error: invalid types 'unsigned char[int]' for array subscript In function 'void loop()':/me
|
|
|
|
|
47
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: 16x8 RGB Matrix Coding Problems
|
on: April 11, 2009, 09:59:56 am
|
|
Now that I have changed that, I get this error:
In function 'void loop()': error: invalid initialization of non-const reference of type 'byte&' from a temporary of type 'byte*' In function 'void runImage(byte&, int&)':
I'm not quite sure what this means as I am not too experienced with C++ functions. Most of this was a mixture of luck and reading example [which are usually about maths]
/me
|
|
|
|
|
49
|
Forum 2005-2010 (read only) / Syntax & Programs / 16x8 RGB Matrix Coding Problems
|
on: April 11, 2009, 09:27:48 am
|
I have developed this so far: #include <Tlc5940.h> #define NUM_CHNLS 48 // The number of LEDs = 3 TLCs * 16
// Column Colour Channels byte redChannels[16] = { 0 ,1 ,2 ,3 ,4 ,5 ,6 ,7, // TLC1: 0 - 7 16,17,18,19,20,21,22,23}; // TLC2:16-23 byte greenChannels[16] = { 8 ,9 ,10,11,12,13,14,15, // TLC1: 8 - 15 24,25,26,27,28,29,30,31}; // TLC2:24-31 byte blueChannels[16] = { 32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47}; // TLC3:32-47 // Row Pins byte rowPins[8] = { 0,1,2,3,4,5,6,7};
int image1R[16][8] = { 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xcff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xbff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xaff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0x9ff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x8ff, 0x7ff, 0x6ff, 0x5ff, 0x4ff, 0x3ff, 0x2ff, 0x1ff, 0xff, 0xfff, 0xeff, 0xdff, 0xcff, 0xbff, 0xaff, 0x9ff};
void setup(){ Tlc.init(); for(int i=0; i<8; i++){ pinMode(rowPins, OUTPUT); } }
void loop(){ runImage(redChannels, image1R); }
void runImage(byte &colourChannels, int &imageArray){ for(int y=0; y<8; y++){ digitalWrite(rowPins[y], HIGH); digitalWrite(rowPins[!y], LOW); for(int i=0; i<16; i++){ Tlc.set(colourChannels[y], imageArray); } } } I created the void runImage() function to scan across the rows and set data for the pixels across the columns from image1R (being the first image set for Red Values) But I get this error: In function 'void loop()': error: 'runImage' was not declared in this scope In function 'void runImage(byte&, int&)':/me
|
|
|
|
|
54
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Help me with analogRead()
|
on: April 04, 2009, 11:34:04 am
|
You're generating the random value into 'val' but not using the value i.e. you're not writing the value of 'val' to the PWM pin. I think it should be like: int ledPin = 9; // LED connected to digital pin 13 int potPin = 2; // Define a pin for pot int val = 0; // hold a random value int time = 1000; // hold the time between loops
void setup() { // run once, when the sketch starts pinMode( ledPin, OUTPUT ); // sets the digital pin as output }
void loop() { // run over and over again val = random( 0, 255 ); // Generate a random number time = analogRead( potPin ); // Get the value from pot analogWrite( ledPin, val ); // sets the LED brightness to random value delay( time ); // waits for a second analogWrite( ledPin, val ); delay( time ); } And it should be a random value from 0 - 255 which is 256 steps.
|
|
|
|
|
55
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: void functions
|
on: April 07, 2009, 06:23:56 pm
|
Say you had the code: unsigned long previousMillis; long interval = 4000;
void setup(){}
void loop() { previousMillis = millis(); if(millis() - previousMillis < interval) { } } You could condense this into a function [void because it doesn't return a data type]. unsigned long previousMillis;
void setup(){ }
void loop() { pause(1000); }
void pause(long interval) { previousMillis = millis(); if(millis() - previousMillis < interval) { } } See here: http://www.arduino.cc/en/Reference/FunctionDeclaration/me
|
|
|
|
|
58
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Edit: First (Simple) Library Not Working
|
on: April 07, 2009, 09:08:54 am
|
Now that I have what I think is the right code for the library: #include "WProgram.h" #include "Sts.h"
byte charactersCap[26][16] = { {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A {1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,1}, // B {1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1}, // C {1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1}, // D {1,0,0,1,0,0,0,1,1,1,0,0,0,1,0,1}, // E {1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1}, // F {1,0,0,1,0,0,0,1,1,1,1,0,1,0,0,1}, // G {0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0}, // H {1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1}, // I {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1}, // J {0,0,0,1,1,0,0,1,0,0,0,1,0,0,1,0}, // K {0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0}, // L {1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1}, // M {0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N {1,0,0,1,0,0,0,1,1,1,1,0,0,1,0,1}, // O {1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1}, // P {1,0,0,1,0,0,0,1,1,1,1,1,0,1,0,1}, // Q {1,0,0,1,1,0,0,1,0,0,0,1,1,1,0,1}, // R {1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,1}, // S {1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1}, // T {0,0,0,1,0,0,0,1,1,1,1,0,0,1,0,0}, // U {0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0}, // V {0,0,0,1,0,1,0,1,1,1,1,0,0,1,0,0}, // W {0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0}, // X {0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0}, // Y {1,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1}}; // Z
Sts::Sts(){ for(int i=2; i<17; i++){ pinMode(i, OUTPUT); } }
void Sts::displayCap(int _charNum) { for(int i=0; i<15; i++) { digitalWrite((i+2), charactersCap[_charNum][i]); } } #ifndef Sts_h #define Sts_h
#include "WProgram.h"
class Sts { public: Sts(); int _charNum; void displayCap(int _charNum); byte charactersCap[26][16]; private: };
#endif And the basic example: #include <Sts.h>
void setup(){ }
void loop() { for(int i=0; i<26; i++) { Sts.displayCap(i); delay(500); } } But I still get this error: In function 'void loop()': error: expected unqualified-id before '.' tokenSo I think I'm implementing something wrong...
|
|
|
|
|
59
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: First Library; works, but error with use
|
on: April 07, 2009, 03:24:08 am
|
OK thanks, that was missing; but now I get this error: In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:4,
from hardware\libraries\Sts/Sts.h:5,
c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:6,
from hardware\libraries\Sts/Sts.h:5, #include "WProgram.h" #include "Sts.h"
byte charactersCap[26][16] = { {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A {1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,1}, // B {1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1}, // C {1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1}, // D {1,0,0,1,0,0,0,1,1,1,0,0,0,1,0,1}, // E {1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1}, // F {1,0,0,1,0,0,0,1,1,1,1,0,1,0,0,1}, // G {0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0}, // H {1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1}, // I {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1}, // J {0,0,0,1,1,0,0,1,0,0,0,1,0,0,1,0}, // K {0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0}, // L {1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1}, // M {0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N {1,0,0,1,0,0,0,1,1,1,1,0,0,1,0,1}, // O {1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1}, // P {1,0,0,1,0,0,0,1,1,1,1,1,0,1,0,1}, // Q {1,0,0,1,1,0,0,1,0,0,0,1,1,1,0,1}, // R {1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,1}, // S {1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1}, // T {0,0,0,1,0,0,0,1,1,1,1,0,0,1,0,0}, // U {0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0}, // V {0,0,0,1,0,1,0,1,1,1,1,0,0,1,0,0}, // W {0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0}, // X {0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0}, // Y {1,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1}}; // Z
void Sts::displayCap(int _charNum) { for(int i=0; i<15; i++) { digitalWrite((i+2), charactersCap[_charNum][i]); } }
void Sts::displaySml(int _charNum) { for(int i=0; i<15; i++) { digitalWrite((i+2), charactersCap[_charNum][i]); } }
void Sts::displayNum(int _charNum) { for(int i=0; i<15; i++) { digitalWrite((i+2), charactersCap[_charNum][i]); } } #ifndef Sts_h #define Sts_h
#include "WConstants.h" #include "WProgram.h"
class Sts { public: void displayCap(int _charNum); void displaySml(int _charNum); void displayNum(int _charNum); private: int _charNum; byte charactersCap[26][16]; };
#endif Here's the .cpp and .h files of my library. [edit]I have only included one font table as they take a long time to make and take up a lot of space.[/edit] Cheers, /me
|
|
|
|
|
60
|
Forum 2005-2010 (read only) / Syntax & Programs / Edit: First (Simple) Library Not Working
|
on: April 06, 2009, 06:34:46 pm
|
|
[edit]Ever tinker I try brings up new or the same errors! See code below...[/edit] I have just created my first (working) library. It give simple use of a Seventeen segment LED display using almost all digital (and analogue) I/O.
I compiled the library fine after a long time of tinkering, but when I can o compile an example I got this error:
In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:4,
c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:6,,
What does this mean?
Thanks, /me
|
|
|
|
|