Snarf 4 rokov pred
commit
4146a215e1

+ 39 - 0
README.md

@@ -0,0 +1,39 @@
+# Veilleuse
+
+Petit projet de veilleuse pour ma fille. Mais je pense qu'il va y avoir des demandes ;p
+
+# Projet 
+
+Le projet se base sur la [Glowing Moon](https://www.thingiverse.com/thing:2531838) auquel j'ai greffé un arduino nano, des led RGB, une photoresistance. 
+
+# BOM 
+
+* Les parties à imprimer en 3D
+* Un arduino nano (ou autre chose)
+* Des leds RGB `ws2812b` ou autre chose supporté par `Adafuit_Neopixel`. Dans mon cas, une barrette de 8 diodes
+* Une resistance de 10kΩ 
+* Un photoresistance 
+
+# Configuration du code
+
+Les principales valeurs à adapter sont les suivantes : 
+
+```c
+// Config Leds
+#define PIN          2
+#define NUMPIXELS    8
+
+// Config Photoresistance
+#define LIGHT_SENSOR A0
+
+// Config couleur
+#define R 255
+#define G 128
+#define B 56
+
+// Config seuil
+#define ON_LEVEL 200
+#define OFF_LEVEL 500
+0
+```
+

+ 120 - 0
code/veilleuse/veilleuse.ino

@@ -0,0 +1,120 @@
+// Based on Adafruit Neopixel 'simple' sample
+
+#include <Adafruit_NeoPixel.h>
+
+
+#define PIN       2
+#define NUMPIXELS 8
+
+#define R 255
+#define G 128
+#define B 56
+
+#define ON_LEVEL 200
+#define OFF_LEVEL 500
+
+
+
+Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
+
+
+void lightBoot(int r, int g, int n, int b)
+{
+
+  
+  if ((b < 0) || (b > 255)) {
+    return false;
+  }
+
+  int red = floor((r * b) / 100);
+  int green = floor((g * b) / 100);
+  int blue = floor((b * b) / 100);
+
+  pixels.clear();
+  for (int i = 0; i < NUMPIXELS; i++) { // For each pixel...
+    pixels.setPixelColor(i, pixels.Color(red, green, blue));
+  }
+  pixels.show();   // Send the updated pixel colors to the hardware.
+
+}
+
+void lightLevel(int b)
+{
+  if ((b < 0) || (b > 255)) {
+    return false;
+  }
+
+  int red = floor((R * b) / 100);
+  int green = floor((G * b) / 100);
+  int blue = floor((B * b) / 100);
+
+  pixels.clear();
+  for (int i = 0; i < NUMPIXELS; i++) { // For each pixel...
+    pixels.setPixelColor(i, pixels.Color(red, green, blue));
+  }
+  pixels.show();   // Send the updated pixel colors to the hardware.
+
+}
+
+void lightFadeIn(int d) {
+  pixels.clear();
+  pixels.show();
+  for (int i = 0; i < 100; i ++) {
+    lightLevel(i);
+    delay(d);
+  }
+}
+
+void lightFadeOut(int d) {
+  pixels.clear();
+  pixels.show();
+  for (int i = 100; i >= 0; i --) {
+    lightLevel(i);
+    delay(d);
+  }
+}
+
+
+void setup() {
+  int i;
+  Serial.begin(9600);
+  Serial.println("Booting");
+  pixels.begin();
+  pixels.clear();
+  pixels.show();
+  for (int i = 0; i <=100; i ++) {
+    lightBoot(255,0,0,i);
+    delay(10);
+  }
+  delay(1000);
+  pixels.clear();
+  pixels.show();
+  for (int i = 100; i >= 0; i --) {
+    lightBoot(255,0,0,i);
+    delay(10);
+  }
+  Serial.println("Ready !");
+}
+
+int state = 0;
+
+void loop() {
+  int valeur = analogRead(A0);
+
+  if ((valeur > OFF_LEVEL) && (state == 1)) {
+    Serial.print("Switching OFF : val=");
+    Serial.println(valeur);
+    lightFadeOut(50);
+    state = 0;
+  }
+
+  if ((valeur < ON_LEVEL) && (state == 0)) {
+    Serial.print("Switching ON : val=");
+    Serial.println(valeur);
+    lightFadeIn(50);
+    state = 1;
+  }
+  delay(1000);
+
+}
+

+ 14 - 0
stl/README.md

@@ -0,0 +1,14 @@
+# STL Veilleuse
+
+Modèles Thingverse : 
+
+* [Glowing Moon](https://www.thingiverse.com/thing:2531838)
+* [Glowing Moon Lamp Base](https://www.thingiverse.com/thing:2746894)
+
+> Le repertoine `thingiverse`contient une copie pour archive des deux modèles. Cependant, je vous conseille de vous baser sur les versions présentes sur Thingiverse.
+
+Modèle Customs : 
+
+* [Base Murale](./stl/base-murale.stl)
+* [Capot Inférieur -- WIP](./stl/capot.stl)
+

BIN
stl/stl/base-murale.stl


BIN
stl/thingiverse/Glowing_Moon.zip


BIN
stl/thingiverse/Glowing_Moon_Lamp_Base.zip