Show Posts
Pages: 1 2 [3] 4 5 ... 15
31  Forum 2005-2010 (read only) / Troubleshooting / Re: error: redefinition of 'void setup() on: January 07, 2009, 06:19:09 pm
This can be common. An assumption is that tabs are for new sketches. But they only open another file for some more code; for the same sketch. Meaning you only declare void setup() and void loop() once.

So you may have declared this more than once leading to this error.
32  Forum 2005-2010 (read only) / Syntax & Programs / Generating display on LCD on: October 27, 2010, 10:16:35 am
I am making a game where you have to dodge the mines by moving to different sides of the 'road' or lines on the screen (16*2 LCD)

I am using an 8051 microcontroller but the code for this should be the same...

I want to display a track of mines (or *) on an LCD screen. I can print the *s to the LCD but want them to 'scroll' along as if it were a road. I could use the scroll function but I also want a static 'player' on the right of the screen.

So far I have this: http://pastebin.com/kmGKrZab

This is as far as I have got with the generation of the enemy mines:

Code:
#define ENEMY_SPACES 12                                    // # spaces enemies can exist in
...
char enemy_track1[20] = {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0};      // Sprites of enemies on track 1
char enemy_track2[20] = {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0};      // Sprites of enemies on track 2
...
void generate_enemies(void){
      int j,i;
      for(i=0; i<ENEMY_SPACES; i++){
            for(j=0; j<ENEMY_SPACES; j++){
                  lcd_set_xy(i, 0);                  // Set position of line 1 of enemies
                  printf_fast(enemy_track1[j]);
                  lcd_set_xy(i, 1);                  // Set position of line 2 of enemies
                  printf_fast(enemy_track2[j]);
            }
            speed_delay(1);                              // Delay for enemy speed
            i++                                    // Move enemies up one place on the screen
            if(i=>ENEMY_SPACES){                        // If the next enemy moves past the end position
                  i=0;                              // Start at 0 again
            }
      }
}

Basically the problem I'm having is refreshing the enemies in the block of 12 spaces they should exist in, to give the illusion of the player scrolling across the road...without losing the player. Or should I scroll the road and just refresh the player?

Thanks for any help  smiley
33  Forum 2005-2010 (read only) / Syntax & Programs / Re: LED Matrix Font on: April 22, 2009, 10:18:28 am
It's nice to see people using the Arduino Pastebin. Just don't forget to C++ syntax colouring.

/me
34  Forum 2005-2010 (read only) / Syntax & Programs / Re: LED Matrix Font on: April 15, 2009, 01:33:34 pm
Ah that makes more sense to me. Cheers for all the effort!

/me
35  Forum 2005-2010 (read only) / Syntax & Programs / Re: LED Matrix Font on: April 15, 2009, 01:19:06 pm
Um yeah kinda, all of it. Just don't really understand how it all stitches together.; probably due to my lack of knowledge:(

/me
36  Forum 2005-2010 (read only) / Syntax & Programs / Re: LED Matrix Font on: April 15, 2009, 12:45:50 pm
Wow that's great! Didn't fully understand that implementation but...

Cheers, /me
37  Forum 2005-2010 (read only) / Syntax & Programs / Re: LED Matrix Font on: April 14, 2009, 02:36:35 pm
Here is the updated and complete font file:

http://pastebin.com/f16e00890

Cheers! /me
38  Forum 2005-2010 (read only) / Syntax & Programs / Re: LED Matrix Font on: April 14, 2009, 10:10:07 am
Ah thank you, that makes sense. I was planning to convert the font to PROGMEM, but would have done it sooner if I had understood it!

Cheers, /me
39  Forum 2005-2010 (read only) / Syntax & Programs / LED Matrix Font on: April 12, 2009, 02:46:23 pm
I have written a font for an RGB matrix that uses PWM [TLC5940] to get soft edges and stuff. It's actually a 5*7 for most characters. But some things are smaller, some bigger.

I adapted an actual font and arranged the data in separate multi-dimensional arrays like this:

Code:
// 0 (Zero)
int 0[][]= {0x3FF, 0x7FF, 0xFFF, 0xFFF 0x7FF, 0x3FF,
0x7FF, 0xFFF, 0x00, 0x00 0xFFF, 0x7FF,
0xFFF, 0xFFF, 0x00, 0xFFF, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0x00, 0x00, 0xFFF, 0xFFF,
0xFFF, 0xFFF, 0xFFF, 0x00, 0xFFF, 0xFFF,
0x7FF, 0xFFF, 0x00, 0x00 0xFFF, 0x7FF,
0x3FF, 0x7FF, 0xFFF, 0xFFF 0x7FF, 0x3FF};

[Contains hexadecimal data for 1/2, 3/4 and full brightness]

But I'm not sure the best way to display these on an LED matrix (using the TLC5940 Library btw) without filling the font in with 0x00 which would suck and be Noob!

/me
40  Forum 2005-2010 (read only) / Syntax & Programs / Re: Programs Stops  8x into loop() on: April 13, 2009, 02:54:15 pm
The code so far is good.

Maybe you could condense the button checks to:

if ( digitalRead(button1) == 1) {
   ...
}

which will save a few lines.

You could even make a function to test buttons based on the button name.

/me
41  Forum 2005-2010 (read only) / Syntax & Programs / Re: problem returning array from function... on: April 15, 2009, 05:19:40 am
The array contains two integers and you cannot assign them to a single integer. so you need to choose one value in the array to assign or do some maths!

/me
42  Forum 2005-2010 (read only) / Syntax & Programs / What value will the it return? on: April 14, 2009, 02:39:48 pm
If you address a value in an array that doesn't exist, what value will it return?

e.g. int number[4] = {1, 2, 3, 4,}

int val = number[4];

/me
43  Forum 2005-2010 (read only) / Syntax & Programs / Re: program not allways starting on: April 07, 2009, 09:30:17 am
You need to go into the folder containing the Arduino IDE and all it's components. Then go into -> Hardware -> Libraries -> LiquidCrystal -> LiquidCrystal.cpp
44  Forum 2005-2010 (read only) / Syntax & Programs / Re: Trouble with my switch case on: April 12, 2009, 04:36:38 pm
For a start, I think: if(Serial.available()) should be: while(Serial.available()) because this will only operate the function when it checks if Serial.available is 'TRUE' and it is. Whereas my example will operate the function when Serial.available is 'TRUE'.

Ben aka /me
45  Forum 2005-2010 (read only) / Syntax & Programs / Re: 16x8 RGB Matrix Coding Problems on: April 11, 2009, 03:47:04 pm
I have now sorted this function:

Quote
int runImage(byte colourChannels[NUM_COL_CHNLS], int imageArray[WIDTH][HEIGHT]){
  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, imageArray[y]);
      Tlc.update();
      delay(10);
    }
  }
}

void loop(){
  runImage(redChannels, image1R);
  delay(3000);
}

Cheers for the help smiley /me
Pages: 1 2 [3] 4 5 ... 15