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:31]
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 28: Ligne 34:
   * Sara   * Sara
  
-=== Arduino ===+{{projets:​oeuf_horloge.png?​200}} 
 +{{projets:​horloge_couleur.jpg?​200}} 
 +{{projets:​horloge_couleur_cablage.png?​400}}
  
-<​code>​ +=== Besoins ===
-/* Code Arduino pour projet Horloge à couleur +
-    E-Fabrik'​ 2018.+
  
-    Projet en cours. Code non définitif.+  * 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
  
-    Cette version du code allume la diode RGB +=== Arduino === 
-    en rouge de 0 à 20 secondes +// 
-    en vert de 20 à 40 secondes +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.//​ 
-    ​en bleu de 40 à 59 secondes + 
-    ​pendant chaque minute.+++++ Code Arduino | 
 +<code c> 
 +/*  Color Clock 
 +    ​E-Fabrik'​ 2018 - Pop [lab] 
 + 
 +    ​A clock-like object changes color according to which part of the day it is.
  
-    ​Il renvoit également sur le port série+    ​######## 
 +    WIRING : 
 +    ######## 
 +    Plug a DS3231 chip on 5V/GND 
 +    SDA > A4 
 +    SCL > A5
  
-    ​Connecter un chip DS3231 ​sur le 5V/GND +    ​Use DS3231 ​lib examples to set the time. 
-    ​SDA sur A4 +    ​Warning : Time must be set using summer-time (no daylight saving) for this code to work properly.
-    SCL sur A5+
  
-    ​Relier une diode RGB aux pins 9,10,11+    ​Ledstrips on 5V/GND 
 +    DI > pin 8
  
-    ​A LA FIN DU PROJET ​RETIRER TOUTE COMMUNICATION SÉRIE & TOUT DELAY+    ​Simple switch on 5V/GND 
 +    reading > pin 2 
 +    --> HIGH Summer time, no daylight saving 
 +    --> LOW : Winter time, daylight saving (-1h)
  
-    ​Dernière mise à jour 05/04/2018+    ​Last update ​24/05/2018 - mh8
 */ */
  
 +//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);​+
  
-  //  analogWrite(analogOutPin255);+void lightLeds() { 
 +    for (uint8_t i = 0; i < ledstrip.numPixels();​ i++) { 
 +    ledstrip.setPixelColor(icolor); 
 +    ledstrip.show();​ 
 +  }
 } }
-</​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 
  
-=== 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]]