Différences

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

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
projets:e_fabrik_2018 [05/04/2018 20:34]
Mathieu Hery
projets:e_fabrik_2018 [20/05/2019 19:08] (Version actuelle)
Mathieu Hery
Ligne 1: Ligne 1:
-====== Projets E-Fabrik' ​======+====== Projets E-Fabrik ​2018 ======
  
 ==== Résumé ==== ==== Résumé ====
Ligne 21: Ligne 21:
 ==== David : Horloge à couleur ==== ==== David : Horloge à couleur ====
  
-Un objet/​horloge qui indique les moments de la journée avec une couleur ​plutôt qu'en affichant l'​heure+Un objet/​horloge qui indique les moments de la journée avec une couleur ​
 + 
 +  *6h - 12h : Jaune 
 +  *12h - 14h : Vert 
 +  *14h - 17h : Bleu 
 +  *17h - 20h : Rouge 
 +  *20h - 00h : Blanc
  
 === Apprentis === === Apprentis ===
Ligne 27: Ligne 33:
   * Sammy   * Sammy
   * Sara   * Sara
 +
 +{{projets:​oeuf_horloge.png?​200}}
 +{{projets:​horloge_couleur.jpg?​200}}
 +{{projets:​horloge_couleur_cablage.png?​400}}
 +
 +=== Besoins ===
 +
 +  * 1 carte Arduino Uno
 +  * 1 module DS3231
 +  * 1 ledstrip type Pololu ou Adafruit avec au moins 16 leds
 +  * 1 imprimante 3D
 +  * 1 alimentation 5V avec de la connectique à souder
  
 === Arduino === === Arduino ===
 +//
 +Attention, si besoin de réinitialiser l'​heure dans le chip DS3231 il faut impérativement utiliser l'​heure d'​été pour que le code fonctionne correctement.//​
  
 +++++ Code Arduino |
 <code c> <code c>
-/* Code Arduino pour projet Horloge à couleur +/*  Color Clock 
-    E-Fabrik'​ 2018.+    E-Fabrik'​ 2018 - Pop [lab]
  
-    ​Projet en cours. Code non définitif.+    ​A clock-like object changes color according to which part of the day it is.
  
-    ​Cette version du code allume la diode RGB +    ​######## 
-    ​en rouge de 0 à 20 secondes +    ​WIRING : 
-    ​en vert de 20 à 40 secondes +    ​######## 
-    ​en bleu de 40 à 59 secondes +    ​Plug a DS3231 chip on 5V/GND 
-    ​pendant chaque minute.+    ​SDA > A4 
 +    SCL > A5
  
-    ​Il renvoit également sur le port série+    ​Use DS3231 lib examples to set the time. 
 +    Warning : Time must be set using summer-time (no daylight saving) for this code to work properly.
  
-    ​Connecter un chip DS3231 sur le 5V/GND +    ​Ledstrips on 5V/GND 
-    ​SDA sur A4 +    ​DI > pin 8
-    SCL sur A5+
  
-    ​Relier une diode RGB aux pins 9,10,11+    ​Simple switch on 5V/GND 
 +    reading > pin 2 
 +    --> HIGH : Summer timeno daylight saving 
 +    --> LOW : Winter timedaylight saving (-1h)
  
-    ​A LA FIN DU PROJET : RETIRER TOUTE COMMUNICATION SÉRIE & TOUT DELAY +    ​Last update ​24/05/​2018 ​- mh8
- +
-    Dernière mise à jour : 05/04/2018+
 */ */
  
 +//libs
 #include <​DS3231.h>​ #include <​DS3231.h>​
 #include <​Wire.h>​ #include <​Wire.h>​
 +#include <​Adafruit_NeoPixel.h>​
  
-const int RedPin = 9; +//constants 
-const int GreenPin = 10; +#define SWITCH 2 
-const int BluePin = 11;+#define DATA_PIN 8
  
 +//variables
 DS3231 Clock; DS3231 Clock;
 bool Century = false; bool Century = false;
Ligne 68: Ligne 94:
 byte ADay, AHour, AMinute, ASecond, ABits; byte ADay, AHour, AMinute, ASecond, ABits;
 bool ADy, A12h, Apm; bool ADy, A12h, Apm;
 +
 +Adafruit_NeoPixel ledstrip = Adafruit_NeoPixel(4,​ DATA_PIN, NEO_GRB + NEO_KHZ800);​
 +
 +uint32_t color = (0, 0, 0);
  
 void setup() { void setup() {
-  // Démarrer l'​interface ​I2C+  //Start I2C interface with DS3231
   Wire.begin();​   Wire.begin();​
  
-  pinMode(RedPinOUTPUT); +  pinMode(SWITCHINPUT);
-  pinMode(GreenPin,​ OUTPUT); +
-  pinMode(BluePin,​ OUTPUT);+
  
-  // Start the serial interface+  ​//​Initialize ledstrip 
 +  ledstrip.begin();​ 
 +  ledstrip.show();​ 
 +  ledstrip.setBrightness(100);​ 
 + 
 +  ​//Start serial interface
   Serial.begin(9600);​   Serial.begin(9600);​
 } }
  
 void loop() { void loop() {
-  // Afficher la date et l'​heure stocké dans le DS3231 (chip RTC)+  // Read & show date and time from DS3231 (RTC)
   Serial.print("​Date : ");   Serial.print("​Date : ");
   Serial.print(Clock.getDate(),​ DEC);   Serial.print(Clock.getDate(),​ DEC);
Ligne 90: Ligne 123:
   Serial.print("​20"​);​   Serial.print("​20"​);​
   Serial.print(Clock.getYear(),​ DEC);   Serial.print(Clock.getYear(),​ DEC);
-  Serial.print("​ - Heure : ");+  Serial.print("​ - Time : ");
   Serial.print(Clock.getHour(h12,​ PM), DEC);   Serial.print(Clock.getHour(h12,​ PM), DEC);
   Serial.print(':'​);​   Serial.print(':'​);​
Ligne 97: Ligne 130:
   Serial.print(Clock.getSecond(),​ DEC);   Serial.print(Clock.getSecond(),​ DEC);
  
-  ​if (Clock.getSecond() < 20) { +  ​int buttonState = digitalRead(SWITCH); 
-    ​analogWrite(RedPin,​ 150)+  int hour
-    ​analogWrite(GreenPin, 0); + 
-    ​analogWrite(BluePin0);+  if (buttonState == 1{ 
 +    ​//​Summertime > Do nothing to time 
 +    hour = Clock.getHour(h12PM);
   }   }
-  else if (Clock.getSecond() >20 && Clock.getSecond() < 40) { + 
-    ​analogWrite(RedPin,​ 0); +  ​if (buttonState ​== 0) { 
-    ​analogWrite(GreenPin150); +    ​//​Wintertime > Remove 1 hour from time read 
-    ​analogWrite(BluePin,​ 0);+    ​if (Clock.getHour(h12PM== 0) { 
 +      //Exception when midnight 
 +    ​hour = 23;
   }   }
-  else  +  else { 
-    ​analogWrite(RedPin0); +    ​hour = Clock.getHour(h12PM- 1
-    ​analogWrite(GreenPin,​ 0); +    ​}
-    analogWrite(BluePin,​ 150);+
   }   }
 +
 +  Serial.print("​ - hour var : " );
 +  Serial.print(hour);​
 +
 +
 +
 +  if (hour >= 6 && hour < 12) {
 +    color = ledstrip.Color(255,​ 255, 0);
 +    lightLeds();​
 +  }
 +
 +
 +  else if (hour >= 12 && hour < 14) {
 +    color = ledstrip.Color(0,​ 255, 0);
 +    lightLeds();​
 +  }
 +
 +  else if (hour >= 14 && hour < 17) {
 +    color = ledstrip.Color(0,​ 0, 255);
 +    lightLeds();​
 +  }
 +
 +  else if (hour >= 17 && hour < 20) {
 +    color = ledstrip.Color(255,​ 0, 0);
 +    lightLeds();​
 +  }
 +
 +  else if (hour >= 20) {
 +    color = ledstrip.Color(255,​ 255, 255);
 +    lightLeds();​
 +  }
 +
 +  else {
 +    color = ledstrip.Color(0,​ 0, 0);
 +    lightLeds(); ​
 +  }
 +
  
   Serial.print('​\n'​);​   Serial.print('​\n'​);​
  
-  // POUR FINALISER LE PROJET RETIRER LE DELAY 
-  delay(1000);​ 
 } }
-</​code>​ 
-==== René : Joystick/​souris pour contrôler l'​ordinateur ==== 
  
-Adapter un joystick à fixer sur la chaise de René pour lui servir de souris pour contrôler l'​ordinateur+void lightLeds() { 
 +    for (uint8_t i = 0; i < ledstrip.numPixels();​ i++) { 
 +    ledstrip.setPixelColor(i,​ color); 
 +    ledstrip.show();​ 
 +  } 
 +}
  
-=== Apprentis === 
  
-  ​Abel (du MAS Glasberg)+ 
 +</​code>​ 
 +++++ 
 + 
 +=== Fichiers === 
 + 
 +  ​*[[http://​poplab.maisonpop.fr/​ressources/​3D/​oeuf_OK.123dx|Oeuf,​ fichier 123 Design]] 
 +  *[[http://​poplab.maisonpop.fr/​ressources/​3D/​oeuf_OK.stl|Oeuf,​ fichier STL]] 
 +  *[[http://​poplab.maisonpop.fr/​ressources/​3D/​socle.123dx|Socle,​ fichier 123 Design]] 
 +  *[[http://​poplab.maisonpop.fr/​ressources/​3D/​socle.stl|Socle,​ fichier STL]]