Interactive Devices and Practical Movie Effects

I’m a huge fan of science fiction movies and I think part of the attraction is special effects, more specifically practical effects.  CGI can be a tool for fantastic visions in movies (ex: TRON, Avatar) but a practical effect is a real, physical thing in an actor’s hands while they are shooting a movie.  One side of practical effects is the world of fandom and at the opposite end are the people who make movies like Blade Runner 2049.  (Probably some spoilers in this but if you haven’t seen 2049 yet now you have two problems.)

Assignment 3: p5.js + Arduino

Assignment 3

Due 23:59, 5 Feb, please post a .zip folder with your p5.js folder, Arduino sketch, and Fritzing sketch.  If you can post video, great.

Tie your previous project (or a new one if you like) to a p5.js client: display the state of your client and any relevant sensor data in p5.js.   Use graphics, animation, sound, or any other p5.js feature you think is the best element for displaying this data.

Walking in the Dark

Background: For people who have migrane, it is terribly painful to turn on the light in the room (any light is unbearable at times) or have sound playing, talking would be painful. Even though this doesn’t mean they can’t open their eyes to see things. However, the light and sound sesitivity make it really difficult for them to walk around in the house for certain necesaties.

Therefore, my project is to help people when they have to walk in the dark, and lights cannot be used as an indicator. Instead of lights, I used buzzer as indicator. If the person is too close to the wall on the left, the buzzer on the left (stick on the person’s hand) will vibrate. Same goes to the buzzer on the right. However, if they have a pet at home, the pir sensor attached to their chest will be active and the buzzer will both buzz at a certain meter.

[Insert picture here]

 

Here is the code part of it:


/* Jean Zhang


*/


const int leftDistPin = A1;
const int rightDistPin = A2;
const int pirPin = 8;

const int buzzLeft = 6;
const int buzzRight = 10;

const int critDist = 950; // somewhat arbitrary number

int leftDist = 0;
int rightDist = 0;

int buzzState = 0;
int buzzStatePrev = 0;


bool isPet = false;


void petPresent() {
 if (digitalRead(pirPin == HIGH)) {
 isPet = !isPet;
 }
 Serial.println(isPet);
}


void determineState() {

if (leftDist > critDist) {
 if (rightDist > critDist) {
 buzzState = 1;
 }
 else {
 buzzState = 2;
 }
 }
 else {
 if (rightDist > critDist) {
 buzzState = 3;
 }
 else {
 buzzState = 4;
 }
 }


 if (isPet == true) {
 buzzState = 5;
 }
}

void setup() {
 // put your setup code here, to run once:

Serial.begin(9600);

pinMode(leftDistPin, INPUT);
 pinMode(rightDistPin, INPUT);
 pinMode(pirPin, INPUT);

pinMode(buzzLeft, OUTPUT);
 pinMode(buzzRight, OUTPUT);


 //attach Interrupt
 if (isPet == HIGH) {
 attachInterrupt( digitalPinToInterrupt (pirPin), petPresent, HIGH);
 }
}


void loop() {
 // put your main code here, to run repeatedly:

//read distance and compare to critDist
 leftDist = analogRead(leftDistPin);
 rightDist = analogRead(rightDistPin);

buzzStatePrev = buzzState;
 determineState();

Serial.print("left");
 Serial.print(leftDist);
 Serial.print(" right");
 Serial.println(rightDist);
 Serial.print("buzzState");
 Serial.println(buzzState);

if (buzzStatePrev != buzzState) {
 switch (buzzState) {
 case 1: break;
 case 2:
 digitalWrite(buzzRight, HIGH);
 break;
 case 3:
 digitalWrite(buzzLeft, HIGH);
 break;
 case 4:
 digitalWrite(buzzRight, HIGH);
 digitalWrite(buzzLeft, HIGH);
 break;
 case 5:
 digitalWrite(buzzRight, HIGH);
 digitalWrite(buzzLeft, HIGH);
 delay (500); //@TODO: write a function that does not use delay
 digitalWrite(buzzRight, LOW);
 digitalWrite(buzzLeft, LOW);
 delay (500); // Yeah, try not to use delay
 break;


 }
 }


}