Created
November 6, 2011 17:51
-
-
Save matael/1343232 to your computer and use it in GitHub Desktop.
2 digits arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LATCH 7 // latch commun aux deux 74hc595 | |
#define DS1 8 // data pour le premier | |
#define DS2 10 // data pour le second | |
#define SH_CP1 9 // shift clock pour le premier | |
#define SH_CP2 11 // shift clock pour le second | |
const byte charset[10] = { | |
B10111110, // 0 | |
B00000110, // 1 | |
B01111100, // 2 | |
B01011110, // 3 | |
B11000110, // 4 | |
B11011010, // 5 | |
B11111010, // 6 | |
B00001110, // 7 | |
B11111110, // 8 | |
B11011110}; // 9 | |
void setup() // cette fonction ne sera exécutée qu'une fois | |
{ | |
// On précise bien à l'arduino que ce sont des sorties | |
pinMode(LATCH, OUTPUT); | |
pinMode(DS1, OUTPUT); | |
pinMode(DS2, OUTPUT); | |
pinMode(SH_CP1, OUTPUT); | |
pinMode(SH_CP2, OUTPUT); | |
} | |
void loop() | |
{ | |
int truc_affiche = map(analogRead(0),0,1023,0,99); | |
int dizaine = truc_affiche/10; | |
int unite = truc_affiche%10; | |
digitalWrite(LATCH, LOW); | |
shiftOut(DS1, SH_CP1, LSBFIRST, charset[dizaine]); | |
shiftOut(DS2, SH_CP2, LSBFIRST, charset[unite]); | |
digitalWrite(LATCH, HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment