Wiki

Reso-nance numérique | Arts et cultures libres

Outils du site


projets:clicomaton:accueil

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
projets:clicomaton:accueil [2016/10/07 11:49]
resonance créée
projets:clicomaton:accueil [2017/07/14 14:19] (Version actuelle)
jonathan [Galerie]
Ligne 26: Ligne 26:
 {{:projets:clicomaton:img_3819.jpg?500|}} {{:projets:clicomaton:img_3819.jpg?500|}}
 {{:projets:clicomaton:img_9768-xl.jpg?500|}} {{:projets:clicomaton:img_9768-xl.jpg?500|}}
 +
 +===== Code Arduino =====
 +<code c+> 
 +/**********************************************************
 + DEFINE
 + *********************************************************/
 +// Version du clicomaton (décommenter la version à utiliser)
 +//#define EINS // Grosse boite avec 4 lampes
 +#define ZVEI // Petite boite avec 3 lampes
 +
 +// Fixe ne pas toucher.
 +#define APPUYER  LOW
 +#define LAMP_ON  LOW
 +#define LAMP_OFF HIGH
 +#ifdef EINS
 +#define LAMP 4
 +#else
 +#define LAMP 3
 +#endif
 +
 +// Variable peu être changé.
 +#ifdef EINS
 +//---------------------------
 +// Timing pour la version EINS
 +#define PHOTO_LOOP 3
 +#define DELAY_PHOTO 1140 
 +#define DELAY_LAMP 1115
 +//---------------------------
 +#else
 +//---------------------------
 +// Timing pour la version ZVEI
 +#define PHOTO_LOOP 3
 +#define DELAY_PHOTO 1140 
 +#define DELAY_LAMP 1115
 +//---------------------------
 +#endif
 +
 +
 +/**********************************************************
 + PINS
 + *********************************************************/
 +int led[] = {6, 5, 4, 3}; // Défilement de gauche à droite.
 +int btn = 7; // Bouton de la sourie gauche.
 +
 +
 +/**********************************************************
 + FONCTIONS
 + *********************************************************/
 +void decompte ()
 +{
 +  for ( int c = 0; c < LAMP; c++)
 +      digitalWrite(led[c], LAMP_OFF); 
 +      
 +  for ( int count = 0; count < PHOTO_LOOP; count++)
 +  {
 +    for ( int i = 0; i <LAMP ; i++)
 +    {
 +      digitalWrite(led[i], LAMP_ON);
 +      delay(DELAY_LAMP);
 +      digitalWrite(led[i], LAMP_OFF);
 +    }
 +    delay(DELAY_PHOTO);
 +  }
 +}
 +
 +
 +
 +/**********************************************************
 + SETUP
 + *********************************************************/
 +void setup() {
 +  
 +  // Initialisation des pins.
 +  for ( int i = 0; i < LAMP; i++)
 +  {
 +    pinMode(led[i], OUTPUT);
 +  }
 + 
 +  pinMode(btn, INPUT_PULLUP);
 +}
 +
 +/**********************************************************
 + LOOP
 + *********************************************************/
 +void loop() {
 +
 +  // Lecture du bouton.
 +  if (digitalRead(btn) == APPUYER)
 +  {
 +    decompte();
 +  }
 +  else
 +  { 
 +    for ( int c = 0; c < LAMP; c++)
 +      digitalWrite(led[c], LAMP_ON); 
 +  }
 +}
 +</code> 
 +
 +===== Galerie =====
 +{{gallery>galerie?&crop&lightbox }} 
 +
/home/resonancg/www/wiki/data/attic/projets/clicomaton/accueil.1475833775.txt.gz · Dernière modification: 2016/10/07 11:49 de resonance