Go Down

Topic: Need help starting a sketch on my Rainbowduino (with a ATmega328) [FIXED] (Read 365 times) previous topic - next topic

EpiczTree

When I upload my sketch nothing happens. I have selected "arduino duemilanove w/ ATmega328" for the board. I know it's uploaded because the light on the rainbowduino turns on. This is my first Arduino so I don't really know what i'm doing.

Here is my code

Code: [Select]
#include "Rainbowduino.h"
#include "Snake.h"
Snake snake;

unsigned char PreDirect = RIGHT;
unsigned char CurDirect = RIGHT;
unsigned char PreDirect_temp1;
unsigned char CurDirect_temp1;
unsigned char PreDirect_temp;
unsigned char CurDirect_temp;
boolean Flag_Debounce = 0;
unsigned char PixelX;
unsigned char PixelY;
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
//**********************************************
void GetDirection(void)
{
 int XValue = analogRead(JOYSTICK_X);
 int YValue = analogRead(JOYSTICK_Y);
 if(XValue < 400) CurDirect_temp = LEFT;
 else if(YValue < 400)CurDirect_temp = DOWN;
 else if(XValue > 600)CurDirect_temp = RIGHT;
 else if(YValue > 600)CurDirect_temp = UP;
 else return;
 if(Flag_Debounce == 0)
 {
   Flag_Debounce = 1;
   CurDirect_temp1 = CurDirect_temp;
   return;
 }
 else
 {
   if(CurDirect_temp != CurDirect_temp1)
   {
     Flag_Debounce = 0;
     return;
   }
 }
 PreDirect = CurDirect;
 CurDirect = CurDirect_temp;
 if((PreDirect + CurDirect) == 5)CurDirect = PreDirect;
}

void setup()
{
Serial.begin(9600);
 snake.init();
}

void loop()
{  
 if(Flag_20ms)
{
  GetDirection();
  Flag_20ms = false;
}
if(Flag_300ms)
{
  Rb.blankDisplay();
 snake.SnakeMove(CurDirect);
 Flag_300ms = false;
}
}

johnwasser

Did you successfully get any of the Rainbowduino example programs to run so you can be sure that your hardware is working?

You are using a library called "snake".  Where is the documentation for that?  DId it come with any example programs you could try?

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

EpiczTree

I've tried a simple example program, but the LED matrix still wouldn't work. I think maybe the matrix might be broken.
I got the "Snake" library from the Rainbowduino Wiki (http://www.seeedstudio.com/wiki/Rainbowduino_v3.0)
Maybe that might help?

johnwasser


I've tried a simple example program, but the LED matrix still wouldn't work. I think maybe the matrix might be broken.


Sounds like something is wrong in the hardware.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Riva

Is the matrix the right way round on the Rainbowduino and/or is it the matrix the correct type (common anode IIRC).

EpiczTree

Turns out you were right. The LED matrix was he wrong way XD. Thanks for the help.

Go Up