- Muchas notas - Fran Acién

20241105 - Wearables workshop - coding pirates

12 nov - 3 dec

Materials:

  • 3 AA Battery pack
  • Single LED
  • 6 Wire
  • Circle LED
  • LED strip
  • LED screen

Course organisation:

  1. [12 Nov] Get to know, install and test Getting to know Neopixel, install the software, know the possibitilities, possible projects
  2. [19 Nov] Program and design Explain the different projects, design the project, and solder the electronics
  3. [26 Nov] Make Soldering and programming
  4. [3 Dec] Finish Sewing/glue and finishing projects

[DAY 1] Get to know, connect and install

Test material

Necessary materials:

  • Computer
  • Arduino IDE
  • Arduino UNO
  • 3 LEDS connected in serie
  • Cables to Arduino

Steps:

  1. Install Arduino IDE
    1. Go to https://www.arduino.cc/en/software
  2. Open Arduino IDE, go to File > Examples > Basics > Blink
  3. Press Upload. Check that the LED is blinking
  4. Install Neopixel Library. Go to Library Manager > Search for Adafruit Neopixel > Install
  5. Test Neopixel test. Go to File > Examples > Neopixel > Strandtest
  6. Modify NUMPIXELS to be 3
  7. Press Upload. Check that the LEDS are green.
#include <Adafruit_NeoPixel.h>

#define PIN        6 

#define NUMPIXELS 3

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

void loop() {
  pixels.clear(); // Set all pixel colors to 'off'

  for(int i=0; i<NUMPIXELS; i++) {
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(500); // Pause before next pass through loop
  }
}

Ideas for projects

d766f86d35ed13a1275ee6f2b0b4f8e9.png

ad7da56c4dd6bb6f04b73ba97bcc3e0a.png

c37fc4b714056df51831d968a129d6cd.png

feddf8167f3dc4c6151919fecdadead0.png

6eb08c5ab372421a3b93545b78860470.png

4606b3793ae95f217310112cd9584ec3.png

Work for next day: Think what project you want to work in, bring the clothes for next day.

[DAY 2] Program and design

Arduino program structure

#define VARIABLE 123

void setup(){
    // This is a comment
    // Setup is run once
}

void loop(){
    // Loop is running constantly
}
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Challenge: How can we make the blink faster?

Neopixel program structure

#include <Adafruit_NeoPixel.h>

#define PIN        6 

#define NUMPIXELS 3

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  
  pixels.clear(); 
  pixels.show(); 
}

void loop() {
  pixels.clear(); // Set all pixel colors to 'off'

  pixels.setPixelColor(0, pixels.Color(150, 0, 0));
  pixels.show();
  delay(1000);

  pixels.setPixelColor(1, pixels.Color(0, 150, 0));
  pixels.show();
  delay(1000);

  pixels.setPixelColor(2, pixels.Color(0, 0, 150));
  pixels.show();
  delay(1000);
}

Challenge: How can we display white? How can we make it faster?

Keywords

delay(1000);         // Wait for 1 Sec
delay(5000);         // Wait for 5 Sec
delay(500);         // Wait for 500 Milliseconds
pixels.setPixelColor(0, pixels.Color(0, 0, 0));          // Set pixel number 0 to black
pixels.setPixelColor(1, pixels.Color(255, 0, 0));        // Set pixel number 1 to red
pixels.setPixelColor(2, pixels.Color(0, 255, 0));        // Set pixel number 2 to green
pixels.setPixelColor(0, pixels.Color(0, 0, 255));        // Set pixel number 0 to blue
pixels.setPixelColor(1, pixels.Color(255, 255, 0));      // Set pixel number 1 to yellow
pixels.clear();          // Clean the screen
pixels.show();           // Apply configuration to LEDS
// Repeat 3 times: Put led on color red
for (int i = 0; i < 3; i++) {
  pixels.setPixelColor(i, pixels.Color(255, 0, 0));
  pixels.show();
  delay(100);
}

You can use examples from the library in Examples > Neopixel

Next step - Design your project and solder the leds

[Day 3] Make and Solder

No material is necessary for this day.

[Day 4] Finishing projects

No material is necessary for this day.