Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
fabricademy2017:students:nuria.robles:week_12 [2018/02/15 13:20] nuriafablab_gmail.com |
fabricademy2017:students:nuria.robles:week_12 [2018/02/15 13:32] nuriafablab_gmail.com |
||
---|---|---|---|
Line 56: | Line 56: | ||
**{{ :fabricademy2017:students:nuria.robles:week12_skin_electronics:01_assignment_5.png?nolink&600x495 }}** | **{{ :fabricademy2017:students:nuria.robles:week12_skin_electronics:01_assignment_5.png?nolink&600x495 }}** | ||
+ | |||
+ | ====== Arduino IDE Setup ====== | ||
+ | |||
+ | **I** installed the Gemma Board following these steps in the [[https://learn.adafruit.com/adafruit-arduino-ide-setup/overview|Adafruit Arduino IDE setup guide]] to easily install a pre-configured Arduino IDE to program Gemma! | ||
+ | |||
+ | **Blink!** | ||
+ | |||
+ | After the instalation, is very useful to upload the **blink** code to the board and see that your PC is talking to your board. I followed this [[https://learn.adafruit.com/introducing-gemma/setting-up-with-arduino-ide#|tutorial]] from Adafruit | ||
+ | |||
+ | And whe it all was done, I uploaded the code for the 3 neopixels | ||
+ | |||
+ | #include <Adafruit_NeoPixel.h> \\ #define NUM_LEDS 5 // Number of NeoPixels | ||
+ | |||
+ | #define PIN 1 // DIGITAL pin # where NeoPixels are connected // IMPORTANT: Avoid connecting on a live circuit... | ||
+ | |||
+ | // if you must, connect GND first. | ||
+ | |||
+ | Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN); | ||
+ | |||
+ | void setup() { \\ strip.begin(); \\ strip.setBrightness(100); // 100/255 brightness (about 40%) strip.show(); // Initialize all pixels to 'off' | ||
+ | |||
+ | } | ||
+ | |||
+ | void loop() { \\ for(int j=0; j<256; j++) { | ||
+ | |||
+ | for(int i=0; i<NUM_LEDS; i++) { strip.setPixelColor(i, Wheel((i * 8 + j) & 255)); | ||
+ | |||
+ | } | ||
+ | |||
+ | strip.show(); | ||
+ | |||
+ | delay(20); | ||
+ | |||
+ | } } | ||
+ | |||
+ | // Input a value 0 to 255 to get a color value. \\ // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { | ||
+ | |||
+ | if(WheelPos < 85) { \\ return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); | ||
+ | |||
+ | } else if(WheelPos < 170) { \\ WheelPos -= 85; \\ return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); | ||
+ | |||
+ | } else { \\ WheelPos -= 170; \\ return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); | ||
+ | |||
+ | } } | ||
\\ | \\ | ||