Images

Project #2: hybrid interaction.

20140304-142410.jpg20140310-105835.jpg20140310-105849.jpg

20140310-105903.jpg20140310-105927.jpg

In the images above you will see the construction of the ferris wheel as well as the main 2 sensors on the breadboard.

Coding for my project for all 3 sensors

#include <Servo.h>
Servo myServo;

int const potPin = A0;
int potVal;
int angle;
const int switchPin = 2;
const int motorPin = 9;
int switchState;
int lastswitchState = LOW;
int onOff = LOW;

//LEDsensor lighting coding in which changes the colors of the main LED light.

const int greenLEDPin = 12;
const int redLEDPin = 11;
const int blueLEDPin = 10;

const int  redSensorPin = A1;
const int  greenSensorPin = A2;
const int  blueSensorPin = A3;

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

int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;

void setup() {
myServo.attach(8);

Serial.begin(9600);

//motor setup
pinMode(motorPin, OUTPUT);
pinMode(switchPin, INPUT);

//LED setup
Serial.begin(9600);

pinMode(greenLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
}
// Make sure the object and sensor does not loop.
void loop() {
potVal = analogRead(potPin);
Serial.print(“potVal: “);
Serial.print(potVal);

angle = map(potVal, 0, 1023, 0, 179);
Serial.print(“, angle: “);
Serial.print(angle);

myServo.write(angle);
delay(15);

switchState = digitalRead(switchPin);

redSensorValue = analogRead(redSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5);
blueSensorValue = analogRead(blueSensorPin);

Serial.print(“Raw Sensor Value \t Red: “);
Serial.print(redSensorValue);
Serial.print(“\t Green: “);
Serial.print(greenSensorValue);
Serial.print(“\t Blue: “);
Serial.print(blueSensorValue);

redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;

Serial.print(“mapped Sensor Value \t Red: “);
Serial.print(redValue);
Serial.print(“\t Green: “);
Serial.print(greenValue);
Serial.print(“\t Blue: “);
Serial.print(blueValue);

analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);

//this is for the motor code ON/OFF

if (switchState == HIGH && lastswitchState == LOW) {
if(onOff == LOW) {
onOff = HIGH;
}
else if(onOff == HIGH) {
onOff = LOW;
}
lastswitchState == HIGH;
if (switchState == LOW) {
lastswitchState = LOW;
}
}

digitalWrite(motorPin, onOff);
}