Concept:
This is my piece called “Come to me, not”. Inspired by the plant Mimosa Pudica, it’s a wearable shield which puts up its defense when aperson comes too close! I’m interested in improving communication by testing out what it feels like to have the functions of other things and people. I used two servo motors to control the wings, and coded them with the code below. I wanted the effect to be a combination of futuristic and natural, and so I used silver wire to make the wings, but I moulded them into a natural shape. I used a infrared sensor to sense how close intruders were.
Pictures:
Code:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
#include
Servo myservo1; // create servo object to control a servo
Servo myservo2;
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int pos=0;
int pos2= 80;
int pos3= 30;
int posinfra = -180;
int posinfra2 = 70;
int posinfrars = -200; //starting point of right
void setup()
{ Serial.begin(9600);
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(8); // attaches the servo on pin 8 to the servo object
myservo1.write(pos); //writes starting position of first servo
myservo2.write(pos2); //write startingposition of second servo
}
void loop()
{
val = analogRead(potpin);
// reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 100, 0, 179);
Serial.println(val); // scale it to use it with the servo (value between 0 and 180)
if (val > 300) {myservo1.write(posinfra); //moves myservo1 to pos 0
//myservo1.write(val); // sets the servo position according to the scaled value
delay(100); // waits for the servo to get there
}
if (val > 600) {
myservo2.write(pos2); //moves myservo2 to pos 0
//myservo1.write(val); // sets the servo position according to the scaled value
delay(100); // waits for the servo to get there
}
if (val < 200) { myservo2.write(pos3); delay(100); } if (val > 600) {
myservo1.write(posinfrars); //moves myservo1 to pos 0
//myservo1.write(val); // sets the servo position according to the scaled value
delay(100); // waits for the servo to get there
}
if (val < 200) {
myservo1.write(posinfra2);
delay(100);
}
}