Trump Head- Physical Computing Midterm

Andrew and I decided on making a talking trump head for our Physical Computing midterm. We bought a rubber Trump mask for its malleability and flexibilty, and because of all the room it has inside to fit the hardware we were going to use.

The concept is a talking head/ ball that is meant to be tossed around, and in doing so is meant to treat the personality like a piece of rubber. We also wanted the mask to talk and be self sufficient on its own, without having to be connected to a computer. We connected a sound shield with an sd card reader to an arduino UNO that is triggered by a motion sensor, which is inserted in one of the mask’s eye sockets. When the mask senses a presence it speaks.

We originally made a sound collage of a Trump phrase for Halloween, but we changed it to a Hillary phrase to create a bit of juxtaposition.

There is also a servo connected to the mask’s mouth, so that when the audio is triggered, the servo moves the masks’ mouth.

 

 

 

 

Arduino Code:

#include <SD.h>
#include <pcmConfig.h>
#include <pcmRF.h>
#include <TMRpcm.h>
#include <SPI.h>
#define SD_ChipSelectPin 4
TMRpcm audio;

//using a O O G resistor (3.3 ohms) for IR sensor
//dont delay less than 250 between openMouth & closedMouth

#include <Servo.h>
Servo mouth;

int speakerPin = 3; //digital out
int servoPin = 2; //digital out
int sensorPin = A0; //analog in

int closedMouth = 45;
int openMouth = 180;
int sensorStrength = 500;
unsigned long lengthOfPhrase = 9000; //in milliseconds
unsigned long timePhraseBegin = 0;
boolean movementDetected = false;
boolean speakOnce = false;

void setup() {
  audio.speakerPin = 9;
  Serial.begin(9600);
  mouth.attach(servoPin); 
  mouth.write(closedMouth);

  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail");  
    return;   // don't do anything more if not
  } else {
    Serial.println("SD success"); 
  }
  audio.setVolume(5);
}

void loop() {
  unsigned long timePassed = millis() - timePhraseBegin;
  
  int sensorRead = analogRead(sensorPin);
  
  if(sensorRead > sensorStrength){
    if(!movementDetected){
      Serial.println("ON.");
      timePhraseBegin = millis();
    }
    movementDetected = true;
  } else {
    if(movementDetected && timePassed >= lengthOfPhrase){
      Serial.println("OFF.");
      movementDetected = false;
      speakOnce = false;
    }
  }

  if(movementDetected){
    
    //move mouth
    mouth.write(openMouth);
    delay(250);
    mouth.write(closedMouth);
    delay(250);

    //speak
    if(!speakOnce){
      audio.play("0000.wav");
      speakOnce = true;
    }
    
  } else {
    //close mouth
    mouth.write(closedMouth);

    delay(250);
  }
}

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *