Circuit et Code

Code pour arduino ( source ->arduino.cc/forum/index.php/topic,8859.0.html)

// 7 LED POV

// letter width. since i have 7 LED, then each letter would look like a 7 x 5 matrix
#define WIDTH 5

//library, each letter stored in hex number instead of bit, five hex numbers make a letter; hence each hex number represent a column of a letter.

const byte font [][WIDTH] =
{
{0x00, 0x00, 0x00, 0x00, 0x00}, //null
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //space
{0x00, 0x00, 0x5f, 0x00, 0x00}, //!
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x08, 0x08, 0x3e, 0x08, 0x08}, //+
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x40, 0x00, 0x00, 0x00, 0x00}, //.
{0x20, 0x10, 0x08, 0x04, 0x02}, //nul
{0x3e, 0x41, 0x41, 0x41, 0x3e}, // /
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x14, 0x14, 0x14, 0x14, 0x14}, //=
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x00, 0x02, 0x59, 0x09, 0x06}, //?
{0x00, 0x00, 0x00, 0x00, 0x00}, //nul
{0x7e, 0x09, 0x09, 0x09, 0x7e}, //A
{0x7f, 0x49, 0x49, 0x49, 0x36}, //B
{0x3e, 0x41, 0x41, 0x41, 0x22}, //C
{0x7f, 0x41, 0x41, 0x22, 0x1c}, //D
{0x7f, 0x49, 0x49, 0x49, 0x49}, //E
{0x7f, 0x09, 0x09, 0x09, 0x09}, //F
{0x7e, 0x41, 0x49, 0x49, 0x38}, //G
{0x7f, 0x08, 0x08, 0x08, 0x7f}, //H
{0x00, 0x41, 0x7f, 0x41, 0x00}, //I
{0x30, 0x40, 0x41, 0x7f, 0x01}, //J
{0x7f, 0x08, 0x14, 0x22, 0x41}, //K
{0x7f, 0x40, 0x40, 0x40, 0x40}, //L
{0x7f, 0x02, 0x04, 0x02, 0x7f}, //M
{0x7f, 0x02, 0x0c, 0x10, 0x7f}, //N
{0x3e, 0x41, 0x41, 0x41, 0x3e}, //O
{0x7f, 0x09, 0x09, 0x09, 0x06}, //P
{0x1e, 0x21, 0x21, 0x21, 0x5e}, //Q
{0x7f, 0x09, 0x19, 0x29, 0x46}, //R
{0x26, 0x49, 0x49, 0x49, 0x32}, //S
{0x01, 0x01, 0x7f, 0x01, 0x01}, //T
{0x3f, 0x40, 0x40, 0x40, 0x3f}, //U
{0x07, 0x38, 0x40, 0x38, 0x07}, //V
{0x3f, 0x40, 0x3f, 0x40, 0x3f}, //W
{0x63, 0x14, 0x08, 0x14, 0x63}, //X
{0x07, 0x08, 0x70, 0x08, 0x07}, //Y
{0x61, 0x51, 0x49, 0x45, 0x43} //Z
};

// nous aurons besoin de comparer le temps écoulé entre deux lectures du senseur reed

unsigned long oldmillis = 42;
unsigned long newmillis = 46;
unsigned long laps = 666;
unsigned long intervalle = 0;

//set up pin 0 – 7 as OUTPUT
void setup()
{

// Serial.begin(9600);

for (int k=0;k=0; i–)
{ for (int j=(WIDTH-1); j>=0; j–)
{ PORTD = font[(int)POVstring[i]-0][j]; delayMicroseconds(3000); }
PORTD = B00000000; delayMicroseconds(5050);
}
}

// you simply feed a string to display it. this code only allows capital letters. however, if you add characters or lowercases in the library above, it would also be able to display it. (but then it would minus a different number instead of 65 above)

void loop()
{

if ( analogRead(5)==1023 ) // ATTENTION! REEED REEED!!!

{

newmillis = millis();
// Serial.print(“old = “);
// Serial.println(oldmillis);
// Serial.print(“new = “);
// Serial.println(newmillis);
laps = newmillis-oldmillis;
oldmillis = newmillis;
// Serial.print(“rpm = “);
// Serial.println(laps);

intervalle = min(laps/3, 400);
//Serial.println(intervalle);
// Serial.println();
delay(intervalle);
display(“BONJOUR”); }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s