Pages: [1]   Go Down
Author Topic: Need help starting a sketch on my Rainbowduino (with a ATmega328) [FIXED]  (Read 325 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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:
#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;
 }
}
« Last Edit: July 15, 2014, 07:15:40 pm by EpiczTree » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2584
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Turns out you were right. The LED matrix was he wrong way smiley-lol. Thanks for the help.
Logged

Pages: [1]   Go Up
Jump to: