Claw Using LED's and Servo's
Light Sculpture: Clearance (2023) is the an iteration of Clearance (2022).
Artworks are almost always exhibited in an abundance of light. Radiant, this light invites us to take our time and thoroughly absorb every detail of the artwork. We rarely question whether we’re allowed to perceive. What if the artwork prefers not to be exposed in this light? What if the work itself determines who can see their light? Clearance challenges the entitlement of the visitor, demanding a consensual encounter. It questions the relationship between observing and the observer using light and darkness
This work is meant to move like a claw (hand) that opens and closes. When you stand underneath the work the lights will go off and the work closes itself off. When it's empty the work shines bright and is fully open.
Supplies
Suplies:
- 1 PVC buis van 2 meter
- 3x WorldSemi WS2812B Digitale 5050 RGB LED Strip - 30 LEDs 1m
- 1x Arduino
- Breadboard 400 points
- DuPont Jumper draad Male-Male 20cm 10 draden
- Ultrasonische Sensor - HC-SR04 (distance meter)
- houten plankje (+/- 17 x 14 x 2 cm)
- 4x TowerPro SG90 9G micro servo motor - 180°
- Computer met Arduino geïnstalleerd
- plakband
- sate prikkers
Tools:
- Boormachine
- Mini schroevendraaier (voor servo)
- Hitte föhn
- Textiel zaag
- Schaar
De Buitenkant
- Zaag de PVC buizen in stukken van 50 CM
- snij er je gewensde patroon in met de textiel zaag, voel vrij om eerst te experimenteren op overig materiaal!
- Fohn het middelpunt van de de buis met een hitte fohn een hoek ongeveer 110 graden
Servo Holder
- schets de vorm van de servo in de grote van de servo uit op het hout
- boor naast elke vorm een gat in de grote van de bedrading
- monteer sate prikkers op de servo's, stapel de platte onderdelen van de stokjes indien nodig.
- Als het goed heb je nu iets zoals dit
Wiring the Board
Digital PIN
PIN 5 >> TRIG_PIN (Ultrasonische Sensor)
PIN 6 >> Echo_PIN
PIN 7 >> SERVO_PIN
PIN 8 >> LED strip 01
PIN 9 >> LED strip 02
PIN 10 >> LED strip 03
Je set up ziet er zo uit:
CODE
#include <Adafruit_NeoPixel.h>
#include <Servo.h>
//array10%3
float measurements[100];//= (te zien in serial monitor)
float average = 0; //gemiddelde van die 10 getallen
int loop_count = 0; //telt op
// SERVO
// constants won't change
const int TRIG_PIN = 5; // Arduino pin connected to Ultrasonic Sensor's TRIG pin
const int ECHO_PIN = 6; // Arduino pin connected to Ultrasonic Sensor's ECHO pin
const int SERVO_PIN1 = 7; // Arduino pin connected to Servo Motor's pin
//const int SERVO_PIN2 = 11; // Arduino pin connected to Servo Motor's pin
const int SERVO_PIN3= 12; // Arduino pin connected to Servo Motor's pin
const int SERVO_PIN4 = 13; // Arduino pin connected to Servo Motor's pin
const int DISTANCE_THRESHOLD = 30; // centimeters
Servo servo1; // create servo object to control a servo
//Servo servo2; // create servo object to control a servo 2
Servo servo3; // create servo object to control a servo 3
Servo servo4; // create servo object to control a servo 4
// variables will change:
float duration_us, distance_cm;
// LED
#define PIN1 8 //ledstrip 01
#define PIN2 9 //ledstrip 02
#define PIN3 10 //ledstrip 03
#define NUM_LEDS1 30 //eerste ledstrip is 30 leds
#define NUM_LEDS2 30 //ledstrip
#define NUM_LEDS3 30 //ledstrip
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(NUM_LEDS1, PIN1, NEO_GRB + NEO_KHZ800); //libraries
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(NUM_LEDS2, PIN2, NEO_GRB + NEO_KHZ800); // libararies strip 2
Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(NUM_LEDS3, PIN3, NEO_GRB + NEO_KHZ800); // libararies strip 3
#include <HCSR04.h> Library for HC-SR04 ultrasonic distance sensor.
int hue = 0;
int val = 255; // values LED 1
int hue2 = 0;
int val2 = 255; // values LED 2
int hue3 = 0;
int val3 = 255; // values LED 3
void setup() { // put your setup code here, to run once:
// LED
strip1.begin();
strip1.show(); // Initialize all pixels to 'off'
strip2.begin();
strip2.show();
strip3.begin();
strip3.show();
Serial.begin(9600); //initialize serial port
//SERVO
pinMode(TRIG_PIN, OUTPUT); // set arduino pin to output mode
pinMode(ECHO_PIN, INPUT); // set arduino pin to input mode
servo1.attach(SERVO_PIN1); // attaches the servo on pin .. to the servo object
servo1.write(0);
//servo2.attach(SERVO_PIN2); // attaches the servo on pin .. to the servo object
//servo2.write(0);
servo3.attach(SERVO_PIN3); // attaches the servo on pin .. to the servo object
servo3.write(0);
servo4.attach(SERVO_PIN4); // attaches the servo on pin .. to the servo object
servo4.write(0);
}
void loop() {
//LED
for (int i = NUM_LEDS1; i > 0 ; i-- ) {
strip1.setPixelColor(i, strip1.getPixelColor(i - 1)); //led 1 gaat aan
}
for (int i = NUM_LEDS2; i > 0 ; i-- ) {
strip2.setPixelColor(i, strip2.getPixelColor(i - 1)); //led 2 gaat aan
}
for (int i = NUM_LEDS3; i > 0 ; i-- ) {
strip3.setPixelColor(i, strip3.getPixelColor(i - 1)); //led 3 gaat aan
}
// int dist = distanceSensor.measureDistanceCm(3); // afstand van de sensor in cm
//Serial.println(dist);
// voor de fade
val = val - 50; //lengte leds 1
hue += 2000; //kleurverloop
if ( val < 0 ) val = 0;
val2 = val2 - 50; //;lengte leds 2
hue2 += 2000; //kleurverloop
if ( val2 < 0 ) val2 = 0;
val3 = val3 - 50; //;lengte leds 3
hue3 += 2000; //kleurverloop
if ( val3 < 0 ) val3 = 0;
strip1.setPixelColor(0, strip1.ColorHSV(hue, 255, val));
strip2.setPixelColor(0, strip2.ColorHSV(hue2, 255, val2));
strip3.setPixelColor(0, strip3.ColorHSV(hue3, 255, val3));
//dat hoe vaak 1 aan gaat, kleur
if ( average > DISTANCE_THRESHOLD) { //wanner de disntance minder is dan ..cm
if ( random(10) == 0 ) { //hoe vaak 1 aan
hue = (54613); //kleur
val = 255;
strip1.setPixelColor(0, strip1.ColorHSV(hue, 255, val));
}
if ( random(30) == 0 ) { //hoe vaak 1 aan
Serial.println("1");
hue2 = (25000); //kleur
val2 = 255;
strip2.setPixelColor(0, strip2.ColorHSV(hue2, 255, val2));
}
if ( random(30) == 0 ) { //hoe vaak 1 aan
Serial.println("2");
hue3 = (25000); //kleur
val3 = 255;
strip3.setPixelColor(0, strip3.ColorHSV(hue3, 255, val3));
}
}
strip1.show();
strip2.show();
strip3.show();
//DISTANCE METER
digitalWrite(TRIG_PIN, HIGH);
//delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// measure duration of pulse from ECHO pin
duration_us = pulseIn(ECHO_PIN, HIGH);
// calculate the distance
distance_cm = 0.017 * duration_us;
measurements[loop_count % 100] = distance_cm; // mesurements (reeks van 10 tegtallen) stoppen we distance cm in op de goede plek.
//reset average naar 0
average = 0;
// in dit loopje ga je alle metingen optellen bij elkaar
for (int i = 0; i < 100; i++)
{
average = average + measurements[i]; // mesurements is een bak met 100 laatjes, [i] is een van die bakjes
}
average = average / 100; // maak het gemiddelde door alle metingen door het aantal bakjes te delen
//SERVO
if(average < DISTANCE_THRESHOLD)
servo1.write(180); // rotate servo motor to 180 degree
else
servo1.write(0); // rotate servo motor to 0 degree
//if(average < DISTANCE_THRESHOLD)
// servo2.write(180); // rotate servo motor to 180 degree
//else
// servo2.write(0); // rotate servo motor to 0 degree
if(average < DISTANCE_THRESHOLD)
servo3.write(180); // rotate servo motor to 180 degree
else
servo3.write(0); // rotate servo motor to 0 degree
if(average < DISTANCE_THRESHOLD)
servo4.write(180); // rotate servo motor to 180 degree
else
servo4.write(0); // rotate servo motor to 0 degree
Serial.print("average: ");
Serial.print(average);
Serial.println(" cm");
loop_count = loop_count + 1; // zorgt dat de 10 door blijft gaan
delay(30); //vetraging van alles
}