Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
fabricademy2017:students:nuria.robles:week_12 [2018/02/15 13:32]
nuriafablab_gmail.com
fabricademy2017:students:nuria.robles:week_12 [2018/02/15 13:35]
nuriafablab_gmail.com
Line 63: Line 63:
 **Blink!** **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+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 And whe it all was done, I uploaded the code for the 3 neopixels
  
-#include <​Adafruit_NeoPixel.h> ​\\ #define NUM_LEDS ​// Number of NeoPixels+<​code>​ 
 +#include <​Adafruit_NeoPixel.h>​ 
 + 
 +#define NUM_LEDS ​// Number of NeoPixels: 3 in my case
  
 #define PIN 1 // DIGITAL pin # where NeoPixels are connected // IMPORTANT: Avoid connecting on a live circuit... #define PIN 1 // DIGITAL pin # where NeoPixels are connected // IMPORTANT: Avoid connecting on a live circuit...
Line 75: Line 78:
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS,​ PIN); 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 setup() { 
 +strip.begin();​ 
 +strip.setBrightness(50); // 100/255 brightness (about 40%) strip.show();​ // Initialize all pixels to '​off'​
 } }
- +void loop() { 
-void loop() { \\ for(int j=0; j<256; j++) { +for(int j=0; j<256; j++) {
 for(int i=0; i<​NUM_LEDS;​ i++) { strip.setPixelColor(i,​ Wheel((i * 8 + j) & 255)); for(int i=0; i<​NUM_LEDS;​ i++) { strip.setPixelColor(i,​ Wheel((i * 8 + j) & 255));
 +    }
 +    strip.show();​
 +    delay(40);
 +}
 +}
  
-  } +// Input a value 0 to 255 to get a color value. 
- +// The colours are a transition r - g - b - back to r. 
-  strip.show();​ +uint32_t Wheel(byte WheelPos) { 
- +if(WheelPos <85) { 
-  delay(20);​ +return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 
- +} else if(WheelPos <170) { 
-} } +WheelPos -= 85; 
- +return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); 
-// 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) { +} else { 
- +WheelPos -= 170; 
-if(WheelPos < 85) { \\ return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); +return strip.Color(0,​ WheelPos * 3, 255 - WheelPos * 3);
- +
-} 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); +
 } } } }
 +</​code>​
  
 \\ \\