Difference between revisions of "Arduino Brucon"

From YobiWiki
Jump to navigation Jump to search
m (Created page with 'Back to Arduino page Here is a first little project. <br>It is using two libraries * http://www.arduino.cc/playground/Code/Metro * http://www.arduino.cc/playground/Code/LED …')
 
m
Line 2: Line 2:
   
 
Here is a first little project.
 
Here is a first little project.
  +
<br>See the result [http://www.flickr.com/photos/doegox/4003188486/ here]
 
<br>It is using two libraries
 
<br>It is using two libraries
 
* http://www.arduino.cc/playground/Code/Metro
 
* http://www.arduino.cc/playground/Code/Metro

Revision as of 21:01, 19 October 2009

Back to Arduino page

Here is a first little project.
See the result here
It is using two libraries

You can download the code [{{#file: brucon.pde}} as brucon.pde]

#include <Metro.h>
#include <LED.h>

LED LED_CircleA = LED(3);
LED LED_CircleB = LED(5);
LED LED_CircleC = LED(6);
Metro METRO_Circle = Metro(100); 
int State_Circle = 0;
struct Steps_Circle_t {
  int CircleA,CircleB,CircleC;
};
struct Steps_Circle_t Steps_Circle[] = {{0xFF,0,0x80},{0x80,0xFF,0},{0,0x80,0xFF}};
int Steps_Circle_size = 3;

LED LED_Left    = LED(0);
LED LED_Middle  = LED(1);
LED LED_Right   = LED(2);
Metro METRO_Box = Metro(400); 
int State_Box = 0;
struct Steps_Box_t {
  int Left,Middle,Right;
};
struct Steps_Box_t Steps_Box[] = {{0,0,0},{0,1,0},
                                  {0,0,0},{1,1,1},
                                  {0,0,0},{1,1,1},{1,1,1},{1,1,1},{1,1,1},{1,1,1},{1,1,1},
                                  {0,0,0},{1,0,0},{1,1,0},{1,1,1},
                                  {1,1,1},{1,1,1},
                                  {0,0,0},{1,1,1},
                                  {0,0,0},{1,1,1},{1,1,1},{1,1,1},{1,1,1},{1,1,1},{1,1,1},
                                };
int Steps_Box_size = 26;

LED LED_B = LED(8);
LED LED_R = LED(9);
LED LED_U = LED(10);
LED LED_C = LED(11);
LED LED_O = LED(12);
LED LED_N = LED(13);
Metro METRO_Brucon = Metro(400); 
int State_Brucon = 0;
struct Steps_Brucon_t {
  int B,R,U,C,O,N;
};
struct Steps_Brucon_t Steps_Brucon[] = {{0,0,0,0,0,0},{1,1,1,1,1,1},
                                        {0,0,0,0,0,0},{1,1,1,1,1,1},
                                        {0,0,0,0,0,0},{1,0,0,0,0,0},{0,1,0,0,0,0},{0,0,1,0,0,0},{0,0,0,1,0,0},{0,0,0,0,1,0},{0,0,0,0,0,1},
                                        {0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},
                                        {1,1,1,1,1,1},{0,0,0,0,0,0},
                                        {0,0,0,0,0,0},{1,1,1,1,1,1},
                                        {0,0,0,0,0,0},{1,0,0,0,0,0},{1,1,0,0,0,0},{1,1,1,0,0,0},{1,1,1,1,0,0},{1,1,1,1,1,0},{1,1,1,1,1,1},
                                       };
int Steps_Brucon_size = 26;

void setup()   {                
}

void loop()                     
{
  if (METRO_Circle.check()) {
    LED_CircleA.setValue(Steps_Circle[State_Circle].CircleA);
    LED_CircleB.setValue(Steps_Circle[State_Circle].CircleB);
    LED_CircleC.setValue(Steps_Circle[State_Circle].CircleC);
    if (++State_Circle == Steps_Circle_size)
      State_Circle = 0;
  }
  if (METRO_Box.check()) {
    LED_Left.setValue  (Steps_Box[State_Box].Left   * 0xFF);
    LED_Middle.setValue(Steps_Box[State_Box].Middle * 0xFF);
    LED_Right.setValue (Steps_Box[State_Box].Right  * 0xFF);
    if (++State_Box == Steps_Box_size)
      State_Box = 0;
  }
  if (METRO_Brucon.check()) {
    LED_B.setValue(Steps_Brucon[State_Brucon].B * 0xFF);
    LED_R.setValue(Steps_Brucon[State_Brucon].R * 0xFF);
    LED_U.setValue(Steps_Brucon[State_Brucon].U * 0xFF);
    LED_C.setValue(Steps_Brucon[State_Brucon].C * 0xFF);
    LED_O.setValue(Steps_Brucon[State_Brucon].O * 0xFF);
    LED_N.setValue(Steps_Brucon[State_Brucon].N * 0xFF);
    if (++State_Brucon == Steps_Brucon_size)
      State_Brucon = 0;
  }   
}