Harduino

Page 1


BHSAD | PD L4

DRAWING LIGHT

Introduction Research and Idea development Exploring Arduino basics..................................................................................................................5

Developing a Prototype Arduino Prototyping...........................................................................................................................15 Studying Arduino controlled light effects.............................................................................23

Final Shell Assembly.........................................................................................................................................31 Infinite Diverging...................................................................................................................................35

In addition

APRIL 2018


Drawing machine. Is Light a media?

That was when it all came together for me. The rest was a detail.

3

When the brief was announced, the first thought was about combining pen and motor somehow. After the first shock passed, I decided to reflect not only the personal ignorance, but also to knowledge and experience. It was discovered, that there were not so a few. I recalled the first time I visited one of the most amazing places – the Gardens by the Bay in Singapore, where manmade trees were illuminating surroundings every night. The images of some favorite artists came to mind, and suddenly I figured out, that most of them are working with light. And sci-fi, old-school one.

Introduction

Developing a drawing machine controlled by mechanisms looked like the impossible task. All these gears and pistons magically spinning round seemed complicated and feasible, but magnificent. Moreover, the learning something called “Arduino” was almost a fantasy story for the person who always tried to avoid any activities related to programming or dealing with electricity. It is amazing, how the love to sci-fi and complete ignorance of “how it all works” could co-exist in one person!


LED Blink Pattern

int yellowled = 13; int greenled = 11; int blueled = 10;

void loop() { digitalWrite(yellowled, HIGH); // turn the LED on delay(100); // wait digitalWrite(yellowled, LOW); // turn the LED off digitalWrite(greenled, HIGH); // turn the LED on delay(100); // wait digitalWrite(greenled, LOW); // turn the LED off digitalWrite(blueled, HIGH); // turn the LED on delay(100); // wait for 1/2 a second digitalWrite(blueled, LOW); // turn the LED off delay(50); // wait

• Color emergence • Light intensity

• Illuminating • Highly reflective

Christinenstraße 18/19 Haus 2, Berlin, 10119 www.olafureliasson.net

}

Research and Idea development

void setup() { pinMode(yellowled, OUTPUT); pinMode(greenled, OUTPUT); pinMode(blueled, OUTPUT); }


DHT11

Exploring Arduino basics

temperature and humidity

GRD #include <DHT.h> #include <DHT_U.h> 220 ohm

#include “DHT.h”

5V

#define DHTPIN 2 DHT dht(DHTPIN, DHT11); void setup() { Serial.begin(9600); dht.begin(); }

5

OMNI MAGAZINE COULD HAVE BEEN READ IN 1978

void loop() { delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println(“Error”); return; } Serial.print(“Humidity: “); Serial.print(h); Serial.print(“ %\t”); Serial.print(“Temperature: “); Serial.print(t); Serial.println(“ *C “); }


Traffic light. Part 1

void setup() { pinMode(PIN_GREEN1, OUTPUT); pinMode(PIN_YELLOW1, OUTPUT); pinMode(PIN_RED1, OUTPUT); digitalWrite(PIN_GREEN1, LOW); digitalWrite(PIN_YELLOW1, LOW); digitalWrite(PIN_RED1, LOW); }

25/06/2014—06/09/2014

The Modern Institute, 3 Aird’s Lane, Glasgow

void loop() { digitalWrite(PIN_GREEN1, HIGH); delay(TIME_GREEN); blinkyellow=true; for(int i=0;i<TIME_ YELLOW;i=i+TIME_BLINK) { if(blinkyellow==true) digitalWrite(PIN_YELLOW1, HIGH); else digitalWrite(PIN_YELLOW1, LOW); delay(TIME_BLINK); blinkyellow=!blinkyellow; } digitalWrite(PIN_GREEN1,LOW); digitalWrite(PIN_YELLOW1, LOW); digitalWrite(PIN_RED1, HIGH); delay(TIME_GREEN); blinkyellow=true; for(int i=0;i<TIME_

YELLOW;i=i+TIME_BLINK) { if(blinkyellow==true) digitalWrite(PIN_YELLOW1, HIGH); else digitalWrite(PIN_YELLOW1, LOW); delay(TIME_BLINK); blinkyellow=!blinkyellow; } digitalWrite(PIN_RED1,LOW); digitalWrite(PIN_YELLOW1, LOW); }

Research and Idea development

#define PIN_GREEN1 10 #define PIN_YELLOW1 11 #define PIN_RED1 13 #define TIME_GREEN 5000 #define TIME_RED 5000 #define TIME_YELLOW 3000 #define TIME_BLINK 300 boolean blinkyellow=true;


int pinleds[6]={13,11,10,6,5,3}; int leds[]={LOW, LOW, LOW, LOW, LOW, LOW,}; #define TIME_GREEN 5000 #define TIME_RED 5000 #define TIME_YELLOW 3000 #define TIME_BLINK 300 boolean blinkyellow=true; void setup() { for(int i=0;i<6;i++) { pinMode(pinleds[i], OUTPUT); digitalWrite(pinleds[i],leds[i]); } }

blinkyellow, HIGH, HIGH, (int) blinkyellow, LOW}; trafficlight(leds4); delay(TIME_BLINK); blinkyellow=!blinkyellow; } }

Exploring Arduino basics

Traffic light. Part 2

void trafficlight(int statled[5]) { for(int i=0;i<6;i++) { digitalWrite(pinleds[i],statled[i]); } }

void loop() { int leds1[]={HIGH, LOW, LOW, LOW, LOW, HIGH}; trafficlight(leds1); delay(TIME_GREEN); blinkyellow=true; for(int i=0;i<(TIME_YELLOW/ TIME_BLINK); i++) { int leds2[]={HIGH, (int) blinkyellow, LOW, LOW, (int) blinkyellow, HIGH}; trafficlight (leds2); delay(TIME_BLINK); blinkyellow=!blinkyellow; }

for(int i=0;i<TIME_YELLOW; i=i+TIME_BLINK) { int leds4[]={LOW, (int)

7

int leds3[]={LOW, LOW, HIGH, HIGH, LOW, LOW}; trafficlight(leds3); delay(TIME_GREEN); blinkyellow=true;


LED Dice

void setup() { for (int i=first; i<=fifth; i++) { pinMode(i, OUTPUT); } pinMode(button, INPUT); randomSeed(analogRead(0)); } void buildUpTension() { for (int i=first; i<=fifth; i++) { if (i!=first) { digitalWrite(i-1, LOW); } digitalWrite(i, HIGH); delay(100); } for (int i=fifth; i>=first; i--) { if (i!=fifth) { digitalWrite(i+1, LOW); } digitalWrite(i, HIGH); delay(100); } } void showNumber(int number) { digitalWrite(first, HIGH); if (number >= 2) { digitalWrite(second, HIGH); } if (number >= 3) { digitalWrite(third, HIGH); } if (number >= 4) { digitalWrite(fourth, HIGH); } if (number >= 5) {

digitalWrite(fifth, HIGH);

}

} int throwDice() { // get a random number in the range [1,6] int randNumber = random(1,7); return randNumber; } void setAllLEDs(int value) { for (int i=first; i<=fifth; i++) { digitalWrite(i, value); } } void loop() { pressed = digitalRead(button); if (pressed == HIGH) { setAllLEDs(LOW); buildUpTension(); int thrownNumber = throwDice(); showNumber(thrownNumber); } }

Research and Idea development

int first = 5; int second = 6; int third = 9; int fourth = 10; int fifth = 11; int button = 13; int pressed = 0;


14

Exploring Arduino basics

LCD Display

МТ–16S2H

15

PIN GRD 5V

#include <LiquidCrystal.h> LiquidCrystal lcd(13, 12, 11, 10, 9, 8); void setup() { lcd.begin(16, 2); lcd.print(“HELL YEAH!”); }

YOU COULD HAVE BEEN SUBSCRIBED IN 1985

9

void loop() { lcd.setCursor(0, 1); lcd.print(“Hate Arduino”); }


Ping Pong

void setup() { Serial.begin(9600); for(int i=0;i<COUNT_LEDS;i++) { pinMode(pinleds[i], OUTPUT); digitalWrite(pinleds[i], LOW); } Serial.println(“start”); setleds(posball); } void loop() { if(res==1) { if((millis()millisgoball)>=speedball) { posball=posball+dirball; if(posball==7) { res=2; posball=7; dirball=-1;

millisres2=millis(); millisblinkres2=millis(); blinkres2=true; } else if(posball==-1) { res=2; posball=0;dirball=1; millisres2=millis(); millisblinkres2=millis(); blinkres2=true; } setleds(posball); millisgoball=millis(); speedball=map(analogRead(POT), 0, 1023, MAX_SPEEDBALL, MIN_ SPEEDBALL); } } if(res==2) { if(millis()-millisblinkres2>= TIME_BLINK_RES2) { blinkres2=!blinkres2; digitalWrite(pinleds[posball], blinkres2); millisblinkres2=millis(); } if(millis()-millisres2>= TIME_ RES2) { digitalWrite(pinleds[posball], HIGH); res=1; } }} void setleds(int pos) { for(int i=0;i<8;i++) digitalWrite (pinleds[i], LOW); digitalWrite (pinleds[pos], HIGH); }

Research and Idea development

#define COUNT_BUTTONS 2 #define COUNT_LEDS 8 const int POT=0; int valpot = 0; int valscale=1000; unsigned long alltimepressing=0; int posball=0; int dirball=1; int pinbuttons[2]={2,3}; int lastbuttons[2]={0,0}; int currentbuttons[2]={0,0}; boolean pressing[2]={false,false}; int res=1; unsigned long speedball=0; unsigned long millisgoball=0; #define MIN_SPEEDBALL 1000 #define MAX_SPEEDBALL 250 unsigned long millisres2=0; #define TIME_RES2 2000 unsigned long millisblinkres2=0; boolean blinkres2=true; #define TIME_BLINK_RES2 200


void setup() { pinMode(redPin1, OUTPUT); pinMode(greenPin1, OUTPUT); pinMode(bluePin1, OUTPUT); pinMode(redPin2, OUTPUT); pinMode(greenPin2, OUTPUT); pinMode(bluePin2, OUTPUT); pinMode(redPin3, OUTPUT); pinMode(greenPin3, OUTPUT); pinMode(bluePin3, OUTPUT);

}

void loop() { sensorValue = analogRead (sensorPin); setColor(255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogReadsensorPin); setColor(255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 135, 0, 255, 127, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 255,

127, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(75, 0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(75, 0, 130, 75, 0, 130, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(75, 0, 130, 75, 0, 130, 75, 0, 130, 0, 0, 0);

delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(75, 0, 130, 75, 0, 130, 75, 0, 130, 75, 0, 130); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(148, 0, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(148, 0, 211, 148, 0, 211, 0, 0, 0, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(148, 0, 211, 148, 0, 211, 148, 0, 211, 0, 0, 0); delay(sensorValue); sensorValue = analogRead(sensorPin); setColor(148, 0, 211, 148, 0, 211, 148, 0, 211, 148, 0, 211); delay(sensorValue); } void setColor(int red, int green, int blue, int red1, int green1, int blue1, int red2, int green2, int blue2, int red3, int green3, int blue3) { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; red1 = 255 - red1; green1 = 255 - green1; blue1 = 255 - blue1 red2 = 255 - red2; green2 = 255 - green2; blue2 = 255 - blue2; red3 = 255 - red3; green3 = 255 - green3; blue3 = 255 - blue3; #endif analogWrite(redPin1, red); analogWrite(greenPin1, green); analogWrite(bluePin1, blue); analogWrite(redPin2, red1); analogWrite(greenPin2, green1); analogWrite(bluePin2, blue1); analogWrite(redPin3, red2); analogWrite(greenPin3, green2); analogWrite(bluePin3, blue2); }

Exploring Arduino basics

int sensorPin = A0; int redPin1 = 13; int greenPin1 = 12; int bluePin1 = 11; int redPin2 = 7; int greenPin2 = 6; int bluePin2 = 5; int redPin3 = 3; int greenPin3 = 2; int bluePin3 = 1; int sensorValue = 0;

11

RGB LED Running Light


RGB Led rainbow 220 ohm

5V 220 ohm

const int RED=13; const int GREEN=11; const int BLUE=10; int red; int green; int blue; const int POT=A0; const int MIN_PAUSE=10; const int MAX_PAUSE=100; int pause; const int VIEW_PAUSE=2000; void setup() { Serial.begin(9600); }

DATA VALUES R, G, B FOR 7 PRIMARY COLORS OF THE RAINBOW Color

R

G

B

red

255

0

0

orange

255

125

0

yellow

255

255

0

green

0

255

0

light blue

0

255

255

blue

0

0

255

purple

255

0

255

void loop() { Serial.println(“red - yellow”); red=255; green=0; blue=0; for(green=0; green<=255; green++) setRGB(red, green, blue); setpause(); delay(VIEW_ PAUSE); setRGB(red, green, blue); setpause(); delay(VIEW_PAUSE); Serial.println(“green - blue”); red=0; green=255; blue=0; for(blue=0; blue<=255; blue++) setRGB(red, green, blue); setpause(); delay(VIEW_PAUSE); setRGB(red, green, blue); setpause(); delay(VIEW_PAUSE); Serial.println(“blue - purple”); red=0; green=0; blue=255;

for(red=0; red<=255; red++) setRGB(red,green,blue); setpause(); delay(VIEW_PAUSE); setRGB(red,green,blue); setpause(); delay(VIEW_PAUSE); } void setRGB(int r, int g, int b) { analogWrite(RED,r); analogWrite(GREEN,g); analogWrite(BLUE,b); delay(pause); } void setpause() { pause=map(analogRead(POT), 0, 1024, MIN_PAUSE, MAX_PAUSE); Serial.print(“pause=”); Serial.println(pause); }

Research and Idea development

220 ohm



Weather station

#include <DHT.h> #include “DHT.h” #include <LiquidCrystal.h> LiquidCrystal lcd(13, 12, 11, 10, 9, 8); #define DHTPIN 3 DHT dht(DHTPIN, DHT11); void setup(){ lcd.begin(16, 2); dht.begin(); }

Environmentally-responsive and powered by wind, Windscreen underscores the relationship between form and performance while engaging timely issues of energy consumption and production. Located on the southern facade of Building 54, Windscreen created an exterior screen composed of an array of small-scale, vertical axis wind turbines. The spinning of these turbines self-powers their integral lighting, providing an active, moving, flickering screen that visibly indexes wind.

Type: Public Space Year: 2011 Location: Cambridge, MA, United States Client: MIT http://www.howeleryoon.com

if (isnan(h) || isnan(t) || isnan(f)) { lcd.print(“NO CONNECTION”); return; } lcd.setCursor(0, 0); lcd.print(h); lcd.print(“ % “); lcd.setCursor(0, 1); lcd.print(t); lcd.print(“ C”); }

150 Lincoln St. 3A Boston, MA 02111

Developing a Prototype

Windscreen

void loop() { delay(1000); float h = dht.readHumidity(); float t = dht.readTemperature(); (isFahrenheit = true) float f = dht.readTemperature(true);


Arduino Prototyping

Color mixer

int inRGB[] = { A0,A1,A2 }; int outRGB[] = { 10,11,13 }; int tempValue = 0; const int inMinVal = 0, inMaxVal = 1023; void setup() { for (int i = 0; i < 3; i++) { pinMode(inRGB[i], INPUT); pinMode(outRGB[i], OUTPUT); } }

geometric forms and animal figures. Freiler and Fels had a masterful ability to work with different materials, such as patinated brass and brilliant chrome.

void loop() { for (int i = 0; i < 3; i++) { tempValue = analogRead(inRGB[i]); tempValue = map(tempValue, inMinVal, inMaxVal, 0, 255); analogWrite(outRGB[i], tempValue); } }

15

The work of Curtis Jeré displays a sense of playfulness and curiosity, while drawing on inspirations and themes that include flowers, discs,


Weather station with LED #include <LiquidCrystal.h> #include <DHT.h> #include “DHT.h” #define DHTPIN A0 #define DHTTYPE DHT11 LiquidCrystal lcd(13, 12, 11, 10, 9, 8); DHT dht(DHTPIN, DHTTYPE); void setup(){ Serial.begin(9600); for (int DigitalPin = 3; DigitalPin <= 7; DigitalPin++) { pinMode(DigitalPin, OUTPUT); } lcd.begin(16,2); dht.begin(); }

} else if (t>22) { digitalWrite(5, HIGH); digitalWrite(3, LOW); digitalWrite(7, LOW); } else if (t>=30) { digitalWrite(7, HIGH); digitalWrite(3, LOW); digitalWrite(5, LOW); } }

void loop(){ delay(1000); ! float h = dht.readHumidity(); float t = dht.readTemperature();

large 3-D light ornaments that are made of hundreds of thousands of light points. Using the tablet provided, they can also rotate the tree in three dimensions.

lcd.setCursor(0,1); lcd.print(“Humid: “); lcd.print(h); lcd.print(“%”); if (t<=22) { digitalWrite(3, HIGH); digitalWrite(5, LOW); digitalWrite(7, LOW);

Developing a Prototype

This is an interactive, threedimensional Crystal tree that is made from a cumulation of light points. It uses Interactive 4-D Vision to display dynamic visuals in real time based on selections made by participants. People can decorate the tree from their smartphones by adding

lcd.clear(); lcd.setCursor(0,0); lcd.print(“Temp: “); lcd.print(t); lcd.print(“’C”);


Arduino Prototyping

Weather station with RGB LED #include <DHT.h> #include <DHT_U.h> #define DHTTYPE DHT11 #define DHTPIN A0 DHT dht(DHTPIN, DHTTYPE); int redPin = 13; int grnPin = 11; int bluPin = 10;

delay(100); digitalWrite(bluPin, LOW); } if((t < 23) && (t > 20.2)) { digitalWrite(grnPin, HIGH); delay(100); digitalWrite(redPin, LOW); digitalWrite(bluPin, LOW); }

void setup(){ Serial.begin(9600); Serial.println(“Humidity and temperature”); delay(1000); pinMode(redPin, OUTPUT); pinMode(grnPin, OUTPUT); pinMode(bluPin, OUTPUT); } void loop(){ float h = dht.readHumidity(); float t = dht.readTemperature();

if((t < 20) && (t > 17.2)) { digitalWrite(grnPin, HIGH); digitalWrite(bluPin, HIGH); delay(100); digitalWrite(redPin, LOW); } if(t <= 17) { digitalWrite(bluPin, HIGH); delay(100); digitalWrite(grnPin, LOW); digitalWrite(redPin, LOW); } delay(1000);

if((t < 26) && (t >= 23.2)) { digitalWrite(redPin, HIGH); digitalWrite(grnPin, HIGH);

}

17

Serial.print(“Current humidity = “); Serial.print(“Humidity: “); Serial.print(h); Serial.print(“% “); Serial.print(“Temperature: “); Serial.print(t); Serial.println(“C “);


Color Mixing LEDs #include <Adafruit_NeoPixel.h>

5V

const int NUMPIXELS = 30; const int LEDsPin = 9; const int redPotPin = A0; const int greenPotPin = A1; const int bluePotPin = A2;

GRD

int redValue = 0; int greenValue = 0; int blueValue = 0;

330 ohm

int redPotValue = 0; int greenPotValue = 0; int bluePotValue = 0; Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LEDsPin, NEO_RGB + NEO_ KHZ800); void setup() { Serial.begin(9600); pinMode(LEDsPin, OUTPUT); }

• • • • • •

12.5mm wide, 4mm thick with casing on, 33mm long per segment 30 LEDs per meter Removable IP65 weatherproof casing Maximum 5V @ 60mA draw per 1.3” strip segment 5VDC power requirement integrated RGB LEDs per segment, individually controllable

void loop() { redPotValue = analogRead(redPotPin); delay(5); greenPotValue = analogRead(greenPotPin); delay(5); bluePotValue = analogRead(bluePotPin); Serial.print(“raw sensor Values \t red: “); Serial.print(redPotValue); Serial.print(“\t green: “); Serial.print(greenPotValue); Serial.print(“\t Blue: “);

Serial.println(bluePotValue); redValue = map(redPotValue, 0, 1023, 0, 255); greenValue = map(greenPotValue, 0, 1023, 0, 255); blueValue = map(bluePotValue, 0, 1023, 0, 255);; Serial.print(“Mapped sensor Values \t red: “); Serial.print(redValue); Serial.print(“\t green: “); Serial.print(greenValue); Serial.print(“\t Blue: “); Serial.println(blueValue); for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, pixels. Color(redValue, greenValue, blueValue)); pixels.show(); delay(50); } }

Developing a Prototype

WS2812


#include <FastLED.h> #include <DHT.h> #define DHTPIN A0 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); #define NUM_LEDS 18 #define DATA_PIN 1 CRGB leds[NUM_LEDS]; void setup() { Serial.begin(9600); while (!Serial) { ; } dht.begin(); }

Arduino Prototyping

Weather station with LED strip Serial.print(“Humidity: “); Serial.print(h); Serial.print(“ %\t”); Serial.print(“Temperature: “); Serial.print(t); Serial.println(“ *C”); } if (t <= 23) {fill_solid( &(leds[0]), NUM_LEDS /*number of leds*/, CRGB::Blue); FastLED.show(); } else { fill_solid( &(leds[0]), NUM_LEDS /*number of leds*/, CRGB::Red); FastLED.show(); } } void loop() { float h = dht.readHumidity(); float t = dht.readTemperature();

19

if (isnan(t) || isnan(h)) { Serial.println(“Failed to read from DHT”); } else {


station basic Prototype: dht11, lcd, led strip #include <LiquidCrystal.h> #include <FastLED.h> #include <DHT.h> #define DHTPIN A0 #define DHTTYPE DHT11 LiquidCrystal lcd(13, 12, 11, 10, 9, 8); DHT dht(DHTPIN, DHTTYPE); #define NUM_LEDS 18 #define DATA_PIN 3

else { lcd.setCursor(0, 0); lcd.print(h); lcd.print(“ % “); lcd.setCursor(0, 1); lcd.print(t); lcd.print(“ C”); }

void setup() {

if (t <= 20) {fill_solid( &(leds[0]), NUM_LEDS /*number of leds*/, CRGB::Blue); FastLED.show(); }

lcd.begin(16, 2); dht.begin(); FastLED. addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_ LEDS);

else { fill_solid( &(leds[0]), NUM_LEDS /*number of leds*/, CRGB::Red); FastLED.show(); }

}

}

CRGB leds[NUM_LEDS];

void loop() {

float h = dht. readHumidity(); float t = dht. readTemperature(); if (isnan(t) || isnan(h)) { lcd.print(“NO CONNECTION”); return; }

Developing a Prototype

delay(1000);


21


void setup() { strip.begin(); strip.show(); } void loop() { ALL CHANGES WILL TAKE PLACE HERE } void showStrip() { #ifdef ADAFRUIT_NEOPIXEL_H // NeoPixel strip.show(); #endif } void setPixel(int Pixel, byte red, byte green, byte blue) { #ifdef ADAFRUIT_NEOPIXEL_H // NeoPixel strip.setPixelColor(Pixel, strip.Color(red, green, blue)); #endif } void setAll(byte red, byte green, byte blue) { for(int i = 0; i < NUM_LEDS; i++ ) { setPixel(i, red, green, blue); } showStrip(); }

void loop() { RGBLoop(); } void RGBLoop(){ for(int j = 0; j < 3; j++ ) { // Fade IN for(int k = 0; k < 256; k++) { switch(j) { case 0: setAll(k,0,0); break; case 1: setAll(0,k,0); break; case 2: setAll(0,0,k); break; }

showStrip(); delay(3); } // Fade OUT for(int k = 255; k >= 0; k--) { switch(j) { case 0: setAll(k,0,0); break; case 1: setAll(0,k,0); break; case 2: setAll(0,0,k); break; } showStrip(); delay(3); } }}

void loop() { FadeInOut(0x4a, 0x80, 0xff); } void FadeInOut(byte red, byte green, byte blue){ float r, g, b; for(int k = 0; k < 256; k=k+1) { r = (k/256.0)*red; g = (k/256.0)*green; b = (k/256.0)*blue; setAll(r,g,b); showStrip(); }

for(int k = 255; k >= 0; k=k-2) { r = (k/256.0)*red; g = (k/256.0)*green; b = (k/256.0)*blue; setAll(r,g,b); showStrip(); } }

Developing a Prototype

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

FADE CUSTOM COLOR

#include <Adafruit_NeoPixel.h> #define PIN 3 #define NUM_LEDS 18 //number of pixels in strip

FADE IN AND FADE OUT

LED Strip Effects


delay(EndPause); }

for(int i = 0; i < NUM_ LEDS-EyeSize-2; i++) { setAll(0,0,0); setPixel(i, red/10, green/10, blue/10); for(int j = 1; j <= EyeSize; j++) { setPixel(i+j, red, green, blue); } setPixel(i+EyeSize+1, red/10, green/10, blue/10); showStrip(); delay(SpeedDelay); }

delay(ReturnDelay); for(int i = NUM_LEDSEyeSize-2; i > 0; i--) { setAll(0,0,0); setPixel(i, red/10, green/10, blue/10); for(int j = 1; j <= EyeSize; j++) { setPixel(i+j, red, green, blue); } setPixel(i+EyeSize+1, red/10, green/10, blue/10); showStrip(); delay(SpeedDelay); }

void loop() { //Sparkle(random(255), random(255), random(255), 10); //random color Sparkle(0xec, 0x70, 0xff, 10); } void Sparkle(byte red, byte green, byte blue, int SpeedDelay) { int Pixel = random(NUM_LEDS); setPixel(Pixel,red,green,blue); showStrip(); delay(SpeedDelay); setPixel(Pixel,0,0,0); }

delay(ReturnDelay); }

23

void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){ for(int j = 0; j < StrobeCount; j++) { setAll(red,green,blue); showStrip(); delay(FlashDelay); setAll(0,0,0); showStrip(); delay(FlashDelay); }

void CylonBounce(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay){

Studying Arduino controlled light effects

SPARKLE EFFECT

CYLON EFFECT

STROBE EFFECT void loop() { // Slower: Strobe(0xff, 0x77, 0x00, 10, 100, 1000); // Fast: //Strobe(0xff, 0xff, 0xff, 10, 50, 1000); }

void loop() { CylonBounce(0x4a, 0xff, 0xa4, 4, 40, 50); }


FIRE EFFECT void loop() { Fire(50,120,20); }

void loop() { RunningLights(0xff,0xff,0x00, 40); }

void Fire(int Cooling, int Sparking, int SpeedDelay) { static byte heat[NUM_ LEDS]; int cooldown;

void RunningLights(byte red, byte green, byte blue, int WaveDelay) { int Position=0; for(int i=0; i<NUM_LEDS*2; i++) { Position++; // = 0; //Position + Rate; for(int i=0; i<NUM_LEDS; i++) { // sine wave, 3 offset waves make a rainbow! //float level = sin(i+Position) * 127 + 128; //setPixel(i,level,0,0); //float level = sin(i+Position) * 127 + 128; setPixel(i,((sin(i+Position) * 127 + 128)/255)*red, ((sin(i+Position) * 127 + 128)/255)*green, ((sin(i+Position) * 127 + 128)/255)*blue); } showStrip(); delay(WaveDelay); } }

void loop() { colorWipe(0x00,0xff,0x00, 80); colorWipe(0x00,0x00,0x00, 80); } void colorWipe(byte red, byte green, byte blue, int SpeedDelay) { for(uint16_t i=0; i<NUM_LEDS; i++) { setPixel(i, red, green, blue); showStrip(); delay(SpeedDelay); } }

for( int k= NUM_LEDS 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k 2]) / 3; }

// Step 1. Cool down every cell a little for( int i = 0; i < NUM_ LEDS; i++) { cooldown = random(0, ((Cooling * 10) / NUM_ LEDS) + 2);

// Step 3. Randomly ignite new ‘sparks’ near the bottom if( random(255) < Sparking ) { int y = random(7); heat[y] = heat[y] + random(160,255); //heat[y] = random(160,255); }

if(cooldown>heat[i]) { heat[i]=0; } else { heat[i]=heat[i]cooldown; } }

// Step 4. Convert heat to LED colors for( int j = 0; j < NUM_ LEDS; j++) { setPixelHeatColor(j, heat[j] ); }

// Step 2. Heat from each cell drifts ‘up’ and diffuses a little

showStrip(); delay(SpeedDelay); }

Developing a Prototype

COLOR WIPE

RUNNING LIGHTS

LED Strip Effects


void theaterChaseRainbow (int SpeedDelay) { byte *c;

byte * Wheel(byte WheelPos) { static byte c[3];

for (int j=0; j < 256; j++) { for (int q=0; q < 3; q++) { for (int i=0; i < NUM_ LEDS; i=i+3) { c = Wheel( (i+j) % 255); setPixel(i+q, *c, *(c+1), *(c+2)); } showStrip(); delay(SpeedDelay); for (int i=0; i < NUM_ LEDS; i=i+3) { setPixel(i+q, 0,0,0); }

if(WheelPos < 85) { c[0]=WheelPos * 3; c[1]=255 - WheelPos * 3; c[2]=0; } else if(WheelPos < 170) { WheelPos -= 85; c[0]=255 - WheelPos * 3; c[1]=0; c[2]=WheelPos * 3; } else { WheelPos -= 170; c[0]=0; c[1]=WheelPos * 3; c[2]=255 - WheelPos * 3; } return c; }

void loop() { BouncingBalls (0xff,0x24,0xd3, 3); } void BouncingBalls (byte red, byte green, byte blue, int BallCount) { float Gravity = -9.81; int StartHeight = 1; float Height[BallCount]; float ImpactVelocityStart = sqrt ( -2 * Gravity * StartHeight ); float ImpactVelocity [BallCount]; float TimeSinceLastBounce [BallCount]; int Position [BallCount]; long ClockTimeSinceLastBounce [BallCount]; float Dampening [BallCount]; for (int i = 0 ; i < BallCount ; i++) { ClockTimeSinceLastBounce [i] = millis(); Height[i] = StartHeight; Position[i] = 0; ImpactVelocity[i] = ImpactVelocityStart; TimeSinceLastBounce[i] = 0; Dampening[i] = 0.90 - float(i)/pow (BallCount,2); } while (true) {

for (int i = 0 ; i < BallCount ; i++) { TimeSinceLastBounce[i] = millis() ClockTimeSinceLastBounce[i]; Height[i] = 0.5 * Gravity * pow ( TimeSinceLastBounce [i]/1000 , 2.0 ) + ImpactVelocity [i] * TimeSinceLastBounce [i]/1000; if ( Height[i] < 0 ) { Height[i] = 0; ImpactVelocity[i] = Dampening[i] * ImpactVelocity[i]; ClockTimeSinceLastBounce[i] = millis(); if ( ImpactVelocity[i] < 0.01 ) { ImpactVelocity[i] = ImpactVelocityStart; } } Position[i] = round( Height[i] * (NUM_LEDS - 1) / StartHeight); } for (int i = 0 ; i < BallCount ; i++) { setPixel(Position[i],red,green,blue); } showStrip(); setAll(0,0,0); } }

25

} } }

Studying Arduino controlled light effects

BOUNCING BALLS

THEATRE CHASE RAINBOW

void loop() { theaterChaseRainbow (80); }


Developing a Prototype

infinity mirror Thermometer


27


full Code for infinity mirror Thermometer #include <Adafruit_NeoPixel.h> #include <LiquidCrystal.h> #include <DHT.h>

lcd.setCursor(0, 1); lcd.print(t); lcd.print(“ C”);

showStrip(); delay(SpeedDelay); }

}

#define PIN 3 #define NUM_LEDS 18 //number of pixels in strip Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800); LiquidCrystal lcd(13, 12, 11, 10, 9, 8); DHT dht(DHTPIN, DHTTYPE); //Setup the NeoPixel Strip int lastTimeCkeched; float h; float t; int cylesPassed = 0; void setup() { lcd.begin(16, 2); dht.begin(); strip.begin(); strip.show(); // Initialize all pixels to ‘off’ Serial.begin(9600); } void loop() { cylesPassed = cylesPassed + 1; Serial.println(cylesPassed); if (cylesPassed >= 150) { h = dht.readHumidity(); t = dht.readTemperature(); Serial.print(“ckecked at “); Serial.println(millis()); if (isnan(t) || isnan(h)) { lcd.print(“NO CONNECTION”); return; } else { lcd.setCursor(0, 0); lcd.print(h); lcd.print(“ % “);

delay(ReturnDelay); cylesPassed = 0; } if (t >= 35) { ColorPlay3(); } else if (t >= 30) { ColorPlay1(); cylesPassed = cylesPassed+1000; } else if (t >= 20) { ColorPlay2(); cylesPassed = cylesPassed+1000; } } ///////WIPE ColorPlay1/////////////////////////// void ColorPlay1() { colorWipe(0xff,0x0f,0x5f, 50); colorWipe(0x00,0x00,0x00, 50); } void colorWipe(byte red, byte green, byte blue, int SpeedDelay) { for(uint16_t i=0; i<NUM_LEDS; i++) { setPixel(i, red, green, blue); showStrip(); delay(SpeedDelay); } } ////////Cylon ColorPlay2/////////////////////////// void ColorPlay2() { CylonBounce(0x4a, 0xff, 0xa4, 2, 30, 50); } void CylonBounce(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay){ for(int i = 0; i < NUM_LEDS-EyeSize-2; i++) { setAll(0,0,0); setPixel(i, red/10, green/10, blue/10); for(int j = 1; j <= EyeSize; j++) { setPixel(i+j, red, green, blue); } setPixel(i+EyeSize+1, red/10, green/10, blue/10);

for(int i = NUM_LEDS-EyeSize-2; i > 0; i--) { setAll(0,0,0); setPixel(i, red/10, green/10, blue/10); for(int j = 1; j <= EyeSize; j++) { setPixel(i+j, red, green, blue); } setPixel(i+EyeSize+1, red/10, green/10, blue/10); showStrip(); delay(SpeedDelay); } delay(ReturnDelay); } /////////FIRE ColorPlay3///////////////////////////////////// void ColorPlay3() { Fire(50,120,20); } void Fire(int Cooling, int Sparking, int SpeedDelay) { static byte heat[NUM_LEDS]; int cooldown; // Step 1. Cool down every cell a little for( int i = 0; i < NUM_LEDS; i++) { cooldown = random(0, ((Cooling * 10) / NUM_LEDS) + 2); if(cooldown>heat[i]) { heat[i]=0; } else { heat[i]=heat[i]-cooldown; } } // Step 2. Heat from each cell drifts ‘up’ and diffuses a little for( int k= NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3; } // Step 3. Randomly ignite new ‘sparks’ near the bottom if( random(255) < Sparking ) { int y = random(7); heat[y] = heat[y] + random(160,255); //heat[y] = random(160,255); }

showStrip(); delay(SpeedDelay); } void setPixelHeatColor (int Pixel, byte temperature) { // Scale ‘heat’ down from 0-255 to 0-191 byte t192 = round((temperature/255.0)*191); // calculate ramp up from byte heatramp = t192 & 0x3F; // 0..63 heatramp <<= 2; // scale up to 0..252 // figure out which third of the spectrum we’re in: if( t192 > 0x80) { // hottest setPixel(Pixel, 255, 255, heatramp); } else if( t192 > 0x40 ) { // middle setPixel(Pixel, 255, heatramp, 0); } else { // coolest setPixel(Pixel, heatramp, 0, 0); } } ////////////////////////////////////////////////////////// void showStrip() { #ifdef ADAFRUIT_NEOPIXEL_H // NeoPixel strip.show(); #endif } void setPixel(int Pixel, byte red, byte green, byte blue) { #ifdef ADAFRUIT_NEOPIXEL_H // NeoPixel strip.setPixelColor(Pixel, strip.Color(red, green, blue)); #endif } void setAll(byte red, byte green, byte blue) { for(int i = 0; i < NUM_LEDS; i++ ) { setPixel(i, red, green, blue); } showStrip(); }

Developing a Prototype

#define DHTPIN A0 #define DHTTYPE DHT11

// Step 4. Convert heat to LED colors for( int j = 0; j < NUM_LEDS; j++) { setPixelHeatColor(j, heat[j] ); }



Final

Shell assembly


31

Process Shell Assembly


Bathroom

TRON designs Corian® (2011)

TRON designs Corian® (2011)

Final

Tron: Legacy (2010)


33

Name of current stage


Final

Infinite Diverging


35

Infinite Diverging


Retro future Bathroom



In addition

another arduino experiments


39

Name of current stage



Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.