Interactive systems

1.  Stepper motor receives rotate command from laptop. This movement triggers piezo sensor1 which activates machine2.
2.  The motion produced by machine2 activates piezo sensor2 which activates machine3.
3.  Machine3 randomly roves and draws.

SCRIPT CODE

#include <Stepper.h>

// change the steps variable to the number of steps on your motor
int steps = 100;
int switchPin  =  9;
int chipPin1 =  10;
int chipPin2 =  11;
int dollPin1 =  8;
int dollPin2 =  12;
int piezoPin1 =  5;
int piezoPin2 =  4;

// create and attaches a stepper motor
// with 100 steps to pins 0, 1, 2 and 3

Stepper stepper(steps, 14,15,16,17);

void setup()
{
pinMode(switchPin,INPUT);
digitalWrite(switchPin,HIGH);
// set the speed of the motor to 20 rpms
stepper.setSpeed(50);
stepper.step(50);
pinMode(dollPin1, OUTPUT);
pinMode(dollPin2, OUTPUT);
pinMode(chipPin1, OUTPUT);
pinMode(chipPin2, OUTPUT);
Serial.begin(9600);
Serial.println(”hello world”);

}

void loop()
{
Serial.println(analogRead(piezoPin1));
if (analogRead(piezoPin1) > 1) {
for (int i=0;i<50;i++) {
digitalWrite(dollPin1, HIGH);
digitalWrite(dollPin2, LOW);
delay(50);
digitalWrite(dollPin1, LOW);
digitalWrite(dollPin2, HIGH);
delay(200);
digitalWrite(dollPin1, LOW);
digitalWrite(dollPin2, LOW);
}
Serial.println(analogRead(piezoPin2));
}
if (analogRead(piezoPin2) > 2) {
for (int i=0;i<5;i++) {
digitalWrite(chipPin1, HIGH);
digitalWrite(chipPin2, LOW);
delay(500);
digitalWrite(chipPin1, LOW);
digitalWrite(chipPin2, HIGH);
delay(500);
digitalWrite(chipPin1, LOW);
digitalWrite(chipPin2, LOW);
}
}
if (Serial.available() > 0) {
int dataIn = Serial.read();
switch(dataIn) {
case(49):  // number 1
stepper.step(50);
break;
case(50):
stepper.step(-50);
break;
case(51):
stepper.step(50);
break;
case(52):
stepper.step(-50);
break;
case(53):
stepper.step(-10);
break;
case(54):
for (int i=0;i<10;i++) {
digitalWrite(dollPin1, HIGH);
digitalWrite(dollPin2, LOW);
delay(random(50));
digitalWrite(dollPin1, LOW);
digitalWrite(dollPin2, HIGH);
delay(random(50));
digitalWrite(dollPin1, LOW);
digitalWrite(dollPin2, LOW);
}
break;
case(55):
for (int i=0;i<10;i++) {
digitalWrite(chipPin1, HIGH);
digitalWrite(chipPin2, LOW);
delay(random(100));
digitalWrite(chipPin1, LOW);
digitalWrite(chipPin2, HIGH);
delay(random(100));
digitalWrite(chipPin1, LOW);
digitalWrite(chipPin2, LOW);
}
break;
}
}

delay(100);
/*
if (digitalRead(switchPin) == HIGH) {
// move 20 steps forward
stepper.step(50);
}
else {
stepper.step(-50);
}
{
digitalWrite(dollPin1, HIGH);
digitalWrite(dollPin2, LOW);
delay(2000);
digitalWrite(dollPin1, LOW);
digitalWrite(dollPin2, HIGH);
delay(2000);
digitalWrite(dollPin1, HIGH);
digitalWrite(dollPin2, LOW);
delay(2000);
}
digitalWrite(chipPin1, HIGH);
delay(5000);
digitalWrite(chipPin2, LOW);
delay(10000);
*/
}

This entry was posted in RS3. Digital Tectonics and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*


× eight = 56


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>