Back to Parent

// Reactive Space and Media Architecture Final Project
// Pittsburgh in View
// Yingyang Zhou, Alex Lin, Ghalya Alsanea, Paggy Zhu, Jason Zhu

int degree1 = 0;
int degree2 = 175;

#include <Servo.h> 
int servo11Pin = 11;
int servol2Pin = 2;
int servol3Pin = 3;
int servol4Pin = 4;
int servol5Pin = 5;
Servo Servol1;
Servo Servol2;
Servo Servol3;
Servo Servol4;
Servo Servol5;

#define sensor0 A0
#define sensor1 A1
#define sensor2 A2


void setup() {
  Serial.begin(9600); // Starts the serial communication
  Servol1.attach(servo11Pin); 
  Servol2.attach(servol2Pin); 
  Servol3.attach(servol3Pin); 
  Servol4.attach(servol4Pin); 
  Servol5.attach(servol5Pin);  
}

void loop() {

  float volts0 = analogRead(sensor0)*0.0048828125;
  int distance0 = 13*pow(volts0, -1); 
  
  float volts1 = analogRead(sensor1)*0.0048828125;
  int distance1 = 13*pow(volts1, -1); 
  
  float volts2 = analogRead(sensor2)*0.0048828125;
  int distance2 = 13*pow(volts2, -1); 

  if(distance0 < 50 || distance1 < 50 || distance2 < 50){
    Servol1.write(degree1);
    Servol2.write(degree1);
    Servol3.write(degree1);
    Servol4.write(degree1);
    Servol5.write(degree1);
    delay(1);
    Servol1.write(degree2);
    Servol2.write(degree2);
    Servol3.write(degree2);
    Servol4.write(degree2);
    Servol5.write(degree2);
    delay(10); 
  }
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0