Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
projets:jozephine [2020/02/15 17:53] – [Jozéphine] mh | projets:jozephine [2020/06/01 16:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Jozéphine ====== | ====== Jozéphine ====== | ||
- | A creepy doll with red leds instead of eyes. The eyes blink 3 times in a cycle when she is moved around. | + | A creepy doll with red leds instead of eyes. |
{{projets: | {{projets: | ||
+ | |||
+ | The eyes blink 3 times in a cycle when she is moved around. | ||
She was built in my beginnings and needs an update. She burns through 3.3V batteries like crazy. | She was built in my beginnings and needs an update. She burns through 3.3V batteries like crazy. | ||
- | ==== Upcoming | + | === Official GitLab Source |
+ | |||
+ | [[https:// | ||
+ | ==== Arduino snippets ==== | ||
+ | |||
+ | === Simple blink === | ||
+ | |||
+ | Wire two leds to pin 0 of atTiny85. Wire two 220 Ohms resistors between each LED and GND. | ||
+ | |||
+ | Each LED should draw a max of 20 mA from the pin which keeps it just under the 40 mA limit. | ||
+ | |||
+ | If you want to wire more LEDs, look into other techniques or use other pins. | ||
+ | |||
+ | ++++ Simple arduino code | | ||
+ | |||
+ | <code c> | ||
+ | int led = 0; // LED pin | ||
+ | int brightness = 0; | ||
+ | int fadeAmount = 5; // points to fade LED by | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(led, | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | fadeEyes(); // blink the eye thing | ||
+ | } | ||
+ | |||
+ | void fadeEyes() | ||
+ | { | ||
+ | analogWrite(led, | ||
+ | if (brightness == 255) | ||
+ | { | ||
+ | delay(1500); | ||
+ | } | ||
+ | |||
+ | brightness = brightness + fadeAmount; | ||
+ | |||
+ | //reverse direction at start & end of fade | ||
+ | if (brightness == 0 || brightness == 255) | ||
+ | { | ||
+ | fadeAmount = -fadeAmount; | ||
+ | } | ||
+ | |||
+ | // wait 30 miliseconds to see changes | ||
+ | |||
+ | delay(30); | ||
+ | } | ||
+ | </ | ||
+ | ++++ | ||
+ | |||
+ | {{projets: | ||
+ | |||
+ | ==== Legacy ==== | ||
+ | |||
+ | ++++ First arduino Code | | ||
+ | |||
+ | <code c> | ||
+ | #import < | ||
+ | |||
+ | int led = 10; // LED pin | ||
+ | int sensor = 2; // Tilt sensor pin | ||
+ | int brightness = 0; | ||
+ | int fadeAmount = 5; // points to fade LED by | ||
+ | int storedVal = 0; // Store value of sensor state | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(sensor, | ||
+ | pinMode(led, | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | int sensorVal = digitalRead(2); | ||
+ | |||
+ | if (sensorVal != storedVal) // if things have moved | ||
+ | { | ||
+ | storedVal = sensorVal; | ||
+ | fadeEyes(); // blink the eye thing | ||
+ | } | ||
+ | else //if not turn led off | ||
+ | { | ||
+ | digitalWrite(led, | ||
+ | } | ||
+ | |||
+ | delay(10); // debounce for sensor | ||
+ | } | ||
+ | |||
+ | void fadeEyes() | ||
+ | { | ||
+ | for (int i = 0; i<312; i++) // | ||
+ | { | ||
+ | analogWrite(led, | ||
+ | if (brightness == 255) | ||
+ | { | ||
+ | delay(750); // stay 3 seconds on full bright led | ||
+ | } | ||
+ | |||
+ | brightness = brightness + fadeAmount; | ||
+ | |||
+ | //reverse direction at start & end of fade | ||
+ | if (brightness == 0 || brightness == 255) | ||
+ | { | ||
+ | fadeAmount = -fadeAmount; | ||
+ | } | ||
+ | |||
+ | // wait 30 miliseconds to see changes | ||
+ | |||
+ | delay(30); | ||
+ | |||
+ | } | ||
+ | |||
+ | digitalWrite(led, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ++++ | ||
- | *fritzing diagram | + | [[https:// |
- | *arduino code | + |