Project 1 – 60-223 Work https://courses.ideate.cmu.edu/60-223/s2018/work Intro to Physical Computing: Student Work Tue, 18 Sep 2018 21:43:43 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.25 Surprise: Needy Wearable https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-needy-wearable/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-needy-wearable/#respond Tue, 18 Sep 2018 20:52:41 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=3850 Needy Wearable is a shirt that reacts heavily when no one is close/when someone is far away, and only calms down the closer one gets. The shirt moves with the help of two servomotors and an ultrasonic ranger positioned on the chest. The wearable goes to a full stop once person2 is within 20cm of the individual wearing the shirt (i.e. way too close).

Process 

Original wearable design plans (cloth draping).

 

 

Movement trials. 

Internal sewing detail. 

Final documentation

 

Working gif

 

Roles

Mohan: wearable creation and design.

Chloé:  programming and wiring.

 

Schematic

 

Code

 

// Needy Wearable: Project I
// by Mohan Yeh (menghany) and Chloé Desaulles (cdesaull)
// Intro to Physical Computing, Fall 2018

// A shirt worn by person1 which moves due to the active state of servomotors
// if a person2 is far away from it. The Needy Wearble calms down
// as the person2 gets closer. 
// This project was built upon the NewPing library sketch.
// ---------------------------------------------------------------------------

#include <NewPing.h>
#include<Servo.h> // Object oriented programming 

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

int pingVal; 

Servo charlie;
const int CHARLIE = 6;

Servo june;
const int JUNE = 9;


NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
  charlie.attach(CHARLIE);
  june.attach(JUNE);
}

void loop() {

  //__________________________________ ULTRASONIC RANGER _____________________________________________
  
  delay(50);                     // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
  Serial.println("cm");

  pingVal = sonar.ping_cm();
  
  //__________________________________ SERVOMOTORS __________________________________________________


//LARGE DISTANCE
  if (pingVal > 100 || pingVal == 0){
  charlie.write(10);
  june.write(10);
  delay(450);
  
  charlie.write(179);
  june.write(179);
  delay(450);

  charlie.write(10);
  june.write(10);
  delay(450);
  
  charlie.write(179);
  june.write(179);
  delay(450);

  charlie.write(10);
  june.write(10);
  delay(450);
  
  charlie.write(179);
  june.write(179);
  delay(450);
    }

//MEDIUM DISTANCE
 else if (50 < pingVal && pingVal <100){

  Serial.println("WORKING?");
  
  charlie.write(10);
  june.write(10);
  delay(600);

  june.write(120);
  charlie.write(120);
  delay(600);

  charlie.write(10);
  june.write(10);
  delay(600);

  june.write(120);
  charlie.write(120);
  delay(600);

  charlie.write(10);
  june.write(10);
  delay(600);

  june.write(120);
  charlie.write(120);
  delay(600);
 }

//TINY DISTANCE
  else if (20 < pingVal && pingVal < 50){

  charlie.write(10);
  june.write(10);
  delay(2000);

  charlie.write(30);
  june.write(30);
  delay(2000);

    
  charlie.write(10);
  june.write(10);
  delay(2000);

  charlie.write(30);
  june.write(30);
  delay(2000);

    
  charlie.write(10);
  june.write(10);
  delay(2000);

  charlie.write(30);
  june.write(30);
  delay(2000);

 }


 //WEARABLE CALM (CLOSE ENOUGH)
  else if (1 < pingVal && pingVal < 19){
    
  //charlie.detach();
  //june.detach();
  charlie.write(10);
  june.write(10);
  delay(2000);
  charlie.write(10);
  june.write(10);
  delay(2000);
 }

}

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-needy-wearable/feed/ 0
Surprise: The “Light Bulb” https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-the-light-bulb/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-the-light-bulb/#respond Mon, 12 Feb 2018 15:47:42 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2523 What We’ve Made?

We created a device that turns a light bulb into a bead confetti globe 🙂

When you push the button that is attached to the light bulb box, instead of expecting for the bulb to be lighten up, you will see many colorful beads bouncing around inside of the light bulb. What a surprise!

How Does it Work?

Essentially we opened and cleaned a real light bulb, and placed it onto a wooden box. A giant push button is connected to an Arduino board inside of the box, which is then connected to a motor and a potentiometer (for controlling the motor speed).

The motor is screwed to a wooden plate, and is placed right below the light bulb. A washer is bended into a hyperbolic shape and hooked onto the motor to serve as a “blender blade”.  The “blade” part of the motor is located inside of the metal neck part of the light bulb.

When press the button once, the Arduino will controll the motor to spin. The attached washer will hit the beads inside of the light bulb, causing them to bounce around. When press it once more, the motor will stop.

Hardware Exterior

Hardware Interior

Hardware Detail

Electronics Wiring Diagram

The Arduino code for controlling the button to the motor is shown below:


int buttonPin = 7; 
int potPin = A0; 
int potVal = 0;
int motorOne = 5;
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0;


void setup() {
 pinMode(buttonPin, INPUT);
 pinMode(potPin, INPUT); 
 pinMode(motorOne, OUTPUT);
 Serial.begin(9600); 
 
}

void loop() {
 potVal = analogRead(potPin);

Serial.print(" potentiometer value: ");
 Serial.print(potVal);
 
 buttonState = digitalRead(buttonPin);
 if (buttonState != lastButtonState) {
 // if the state has changed, increment the counte
if (buttonState == HIGH) {
buttonPushCounter++;
 }
 lastButtonState = buttonState; 
 }


if (buttonPushCounter % 2 == 0) {
 int fanSpeed = map (potVal, 0, 1023, 0, 255);
 analogWrite(motorOne, fanSpeed); 
 Serial.print(" button state: ");
 Serial.print(buttonState); 
 Serial.print("; fan speed: ");
 Serial.println(fanSpeed); 
 
 }
 else{
 int fanSpeed = 0;
 analogWrite(motorOne, fanSpeed);
 Serial.print(" button state: ");
 Serial.print(buttonState); 
 Serial.print("; fan speed: ");
 Serial.println(fanSpeed); 
 }

Serial.print(" button counter: ");
 Serial.print(buttonPushCounter); 
 
 delay(50);

}

The code can also be found via the link below:

https://github.com/willowhong/Light-Bulb-Surprise/blob/master/button_to_motor.ino

What Is the Process?

1. Our initial idea was to use cooling fan to blow air into the light bulb and make a snow globe. However, we found that this is not possible due to built up air pressure.

2. We decided to explore with motor to achieve similar effect.

3. We tried a variety of materials for putting inside of the light bulb, including glitters, paper scraps, pom pom balls, plastic beads, etc.

4. We broke one light bulb due to loose joints between the washer and the motor.

REFLECTION

Throughout our design process we made a number of changes. The majority of these changes were motivated by physical limitations. In our original designs we had planned to use a computer fan to blow glitter into a light bulb. Through testing we quickly discovered that the available fans lacked the power to scatter the glitter. When we initially decided on this idea we hadn’t considered the limitations of the in detail. We had to change direction mid build, moving to the bent washer design, and testing a number of different “confettis”. This process was the most challenging part of the build. The electronic side of the project was comparatively simple.

We used a potentiometer and button to control a dc motor. This was a good introduction to Arduino, but there is a lot of room for growth. If we were to take this project to the next level, we could have used more sensors and inputs to make the product more reactive to its environment. For example, There could have been LEDs in the bulb that light up when the room was dark. That being said we are satisfied with the bulbs current function and aesthetic.

 

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-the-light-bulb/feed/ 0
Surprise: Loud(er) Alarm Clock https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-louder-alarm-clock/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-louder-alarm-clock/#respond Mon, 12 Feb 2018 14:10:36 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2534

Link to video: https://youtu.be/cn9VR3cG1EI

Narrative Description

An alarm clock that gets louder when you try to turn it off. It displays the current time and an alarm countdown on the LCD display, which can be triggered by pressing a push button. When the alarm countdown reaches zero, the alarm (a piezo buzzer) goes off. However, when you press the push button again to turn it off, the alarm gets louder (up to four times). When you are finally awake, you can turn off the alarm clock by twisting two knobs (potentiometers) next to the LCD display.

 

Progress Images

We decided early on to use piezo speakers instead of a more sophisticated speaker. Instead of changing the loudness of each individual speaker (and get a noticeable drop in sound quality), we decided to use four speakers to vary loudness.

 

 

 

 

We added an LCD display to make the product more intuitive. We noticed that most alarm clocks have front facing displays, so we opted to do the same to set up the expectation of a regular alarm clock.

 

 

We put all the parts together, and aggregated our code for the different subsystems into one, to get everything to work together.

 

 

 

 

 

Schematic

 

Code

</pre>
#include <Wire.h>
#include "rgb_lcd.h"

rgb_lcd lcd;

//rgb values
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;

// TONES ==========================================
// Start by defining the relationship between
// note, period, & frequency.
#define c 3830 // 261 Hz
#define d 3400 // 294 Hz
#define e 3038 // 329 Hz
#define f 2864 // 349 Hz
#define g 2550 // 392 Hz
#define a 2272 // 440 Hz
#define b 2028 // 493 Hz
#define C 1912 // 523 Hz
// Define a special note, 'R', to represent a rest
#define R 0

// SETUP ============================================
int speaker_1 = 3;
int speaker_2 = 5;
int speaker_3 = 6;
int speaker_4 = 9;
int button_pin = 8; //increases number of alarms and sets the alarm

int hour = 11;
int minute = 10;
int second = 0;
int alarm_counter = 9;
bool alarm_set = false;

int alarms_on = 0; // the number of alarms that are on
int button_press = 0; // button read
int threshold = 1000;
int pot_1 = 0; // pot read
int pot_2 = 0; // pot read
bool button_prev_pressed = false;

void setup() {
pinMode(speaker_1, OUTPUT);
pinMode(speaker_2, OUTPUT);
pinMode(speaker_3, OUTPUT);
pinMode(speaker_4, OUTPUT);
pinMode(button_pin, INPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);

lcd.begin(16,2);
lcd.setRGB(colorR, colorG, colorB);
}

// MELODY and TIMING =======================================
// melody[] is an array of notes, accompanied by beats[],
// which sets each note's relative length (higher #, longer note)
int melody[] = { C, b, g, C, b, e, R, C, c, g, a, C };
int beats[] = { 16, 16, 16, 8, 8, 16, 32, 16, 16, 16, 8, 8 };
int MAX_COUNT = sizeof(melody) / 2; // Melody length, for looping.

// Set overall tempo
long tempo = 10000;
// Set length of pause between notes
int pause = 1000;
// Loop variable to increase Rest length
int rest_count = 100; //<-BLETCHEROUS HACK; See NOTES

// Initialize core variables
int tone_ = 0;
int beat = 0;
long duration = 0;

// PLAY TONE ==============================================
// Pulse the speaker to play a tone for a particular duration
void playTone() {
long elapsed_time = 0;
if (tone_ > 0) { // if this isn't a Rest beat, while the tone has
// played less long than 'duration', pulse speaker HIGH and LOW
while (elapsed_time < duration) {

if (alarms_on == 4){
digitalWrite(speaker_1,HIGH);
digitalWrite(speaker_2,HIGH);
digitalWrite(speaker_3,HIGH);
digitalWrite(speaker_4,HIGH);
delayMicroseconds(tone_ / 2);

// DOWN
digitalWrite(speaker_1, LOW);
digitalWrite(speaker_2, LOW);
digitalWrite(speaker_3, LOW);
digitalWrite(speaker_4, LOW);
delayMicroseconds(tone_ / 2);

// Keep track of how long we pulsed
elapsed_time += (tone_);
}

else if (alarms_on == 3){
digitalWrite(speaker_1,HIGH);
digitalWrite(speaker_2,HIGH);
digitalWrite(speaker_3,HIGH);
delayMicroseconds(tone_ / 2);

// DOWN
digitalWrite(speaker_1, LOW);
digitalWrite(speaker_2, LOW);
digitalWrite(speaker_3, LOW);
delayMicroseconds(tone_ / 2);

// Keep track of how long we pulsed
elapsed_time += (tone_);
}

else if (alarms_on == 2){
digitalWrite(speaker_1,HIGH);
digitalWrite(speaker_2,HIGH);
delayMicroseconds(tone_ / 2);

// DOWN
digitalWrite(speaker_1, LOW);
digitalWrite(speaker_2, LOW);
delayMicroseconds(tone_ / 2);

// Keep track of how long we pulsed
elapsed_time += (tone_);
}

else if (alarms_on == 1){
digitalWrite(speaker_1,HIGH);
delayMicroseconds(tone_ / 2);

// DOWN
digitalWrite(speaker_1, LOW);
delayMicroseconds(tone_ / 2);

// Keep track of how long we pulsed
elapsed_time += (tone_);
}

else{
break;

}
}
}
else { // Rest beat; loop times delay
for (int j = 0; j < rest_count; j++) { // See NOTE on rest_count
delayMicroseconds(duration);
}
}
}

void loop() {

//print current time
lcd.setCursor(0,0);
lcd.print(hour);
lcd.setCursor(2,0);
lcd.print(':');
lcd.setCursor(3,0);
lcd.print(minute);
lcd.setCursor(5,0);
lcd.print(':');
lcd.setCursor(6,0);
lcd.print(second);

//increment time
second = second + 1;

if (second == 60){
second = 0;
minute = minute + 1;

if (minute == 60){
minute = 0;
hour = hour + 1;

if (hour == 24){
hour = 0;
}
}
}

lcd.setCursor(0,1);
if (alarm_counter>=0){
lcd.print(alarm_counter);
}

button_press = digitalRead(button_pin);

if ((button_press) and (button_prev_pressed)){
button_press = false;
}

if ((button_press) and (!alarm_set) and (alarms_on == 0)){
alarm_set = true;
}

else if ((alarm_set) and (alarm_counter == 0)){
alarm_set = false;
alarms_on = 1;
alarm_counter = 9;
}
else if ((alarms_on > 0) and (alarms_on < 4) and (button_press)){
alarms_on = alarms_on + 1;
}

if (alarm_set){
alarm_counter = alarm_counter - 1;
}

pot_1 = analogRead(A0);
pot_2 = analogRead(A1);

if ((pot_1 > threshold) and (pot_2 > threshold)){
alarms_on = 0;
}

for (int i=0; i<MAX_COUNT; i++) {
tone_ = melody[i];
beat = beats[i];

duration = beat * tempo; // Set up timing

playTone();
// A pause between notes...
delayMicroseconds(pause);

}
}
<pre>


Discussion

The idea behind using four speakers to gradually make the alarm louder by pressing the ”snooze” button multiple times is an attempt to surprise someone by increasing the number of engaged speakers over time as triggered by (snooze) button press.  The waking up person might initially be confused as to why the snooze button made the alarm signal louder.  Upon multiple more snooze button presses, the user begins to realize they are only making the alarm louder by trying to silence it.  As the person becomes more focused they are forced to look for other solutions for turning off the alarm.  By playing around with the two potentiometers next to the LCD display, the user becomes engaged with the device as they troubleshoot ways for quieting the alarm sound.  The natural motion of a radial dial alludes to the idea of volume control and dual dials require two hands to be engaged, encouraging the user to focus on the activity at hand.  

  

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-louder-alarm-clock/feed/ 0
Surprise: Balloon Buster https://courses.ideate.cmu.edu/60-223/s2018/work/project-1-balloon-buster/ https://courses.ideate.cmu.edu/60-223/s2018/work/project-1-balloon-buster/#respond Mon, 12 Feb 2018 04:40:44 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2441 Balloon Surprise
Created by: Josh LeFevre and Nathan Serafin

The design brief:

“Make something surprising. It should be surprising explicitly in the sense that it does not do what most of your classmates expect it would. Giggles are preferred over gasps—aim to induce wonder and delight rather than fright.”

Simple overview

A “hood” like container holds a balloon. This fixture suspends the balloon and components in the air above a door. Next to the balloon is a motor with a pin on it. When the door is opened and trips a sensor, the motor pushes a pin into the balloon causing the balloon to pop and confetti to fly.

THE BALLOON BUSTER

VIDEO HERE

Process

Materials:

  • Arduino Uno
  • jumper wires
  • Servo motor
  • Protoboard/breadboard
  • Magnetic door switch
  • 10K resistor
  • Cardboard
  • Paper tape
  • Fish line
  • utility or xacto knife

Schematic

 

Code

 

/*
 * Turn a servo when a switch throws.
 *
 * The intended use was to pop a balloon when a door opened.
 *
 * Copyright 2018 Josh LeFevre, Nathan Serafin
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software
 * is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <Servo.h>

#define SERVO_PIN 2
#define DOOR_PIN 3

#define POP_ANGLE 120

Servo servo;

void setup()
{
    pinMode(DOOR_PIN, INPUT);

    servo.attach(SERVO_PIN);

    servo.write(0);

    Serial.begin(9600);
}

void loop()
{
    int door_closed = !digitalRead(DOOR_PIN);

    if (door_closed) {
        delay(1000);
        servo.write(POP_ANGLE);
    }
    else {
        servo.write(0);
    }

    delay(50);
}


Public GitHub repository.

Steps

During this project we wanted to explore using stored energy. We settled on using a servo motor to pop a balloon and distribute confetti. Don’t you wish every class would welcome you with confetti?

Product of our initial design meeting.

IDEATION: The initial ideas were prototyped with whiteboard markers and papers. The ideas ranged from putting the balloon over the door, in box on a table, or doing away with the balloon and using release gates.

The idea that the Arduino is unable to supply a significant amount of energy guided our ideas towards storing energy beforehand, and having the Arduino simply release it.  This made the balloon a good prospect.

We felt that a surprise would be best aided by first “startling” the user followed by something pleasant, which led us away from designs that relied on building up tension until the balloon unexpectedly popped.

 

Cutout of hood.

 

PROTOTYPE:  We measured and cut out a “hood” fixture to hold a 5-inch balloon in place, and wired up some simple electronics to sense the door closing and move the pin.

TESTING: We tested our mounting and popping of balloons over a trash can.   Positioning the pin so that it popped the balloon when it moved, but didn’t when we were getting set up was a challenge:  eventually, we put a piece of tape over the pin, which worked well.  We were unable to acquire 5-inch balloons, so we had to be very careful not to over-inflate the 12-inch balloons we did get.  We also realized that, while it seemed natural when the whole device was on the table for the balloon to pop when the switch was closed, that would have meant that when we first put it on the door the balloon would have been popped the moment we applied power.

 

 

Full system test.

For a full functional test, we installed our surprise over the classroom door. This allowed us to test the door magnet sensor.

 

Reflection

This project was a great exploration in using simple systems. Quite literally, the tools used were a simple switch and servo motor with a pin. The simplicity adds to the ability to surprise. In some respects, because the user doesn’t look for ways to figure out how the system works they are able to enjoy the surprise over and over again.

If we were to repeat this project, we would explore ways to make rapid or successive loading of the energy source (balloon) more streamlined and less cumbersome (one at a time).

We were also concerned about the confetti making a mess (which it did):  we considered not using it, but that would have drastically reduced the joy of the project.  While it was fun to startle people, it was even more fun to see the smiles as the confetti went everywhere, and as people walked around with it stuck in their hair.

Final photos

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/project-1-balloon-buster/feed/ 0
SURPRISE: SHY BOX https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-shy-box/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-shy-box/#respond Mon, 12 Feb 2018 03:34:11 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2622 FINAL

 

NARRATIVE  DESCRIPTION

The ShyBot  at first glance, appears to be and ordinary cardboard box.  Upon further inspection, some electronics can be seen, but its true purpose is hidden.  However, as you walk towards it, perhaps to inspect it closer, it skids away.  ShyBot is the box that likes its personal space.  Utilizing two ultrasonic rangers, ShyBot can independently control two motorized wheels to stay away from anyone trying to pop its personal bubble.  It watches in front of itself and makes sure no one gets too close.  If someone does approach it, ShyBot will drive away, and the closer someone gets to it, the faster it’ll drive away.  The independently controlled wheels allows for the ability to turn, as well.  If someone walks towards ShyBot at an angle, ShyBot will turn its wheels so as to both move away and face itself towards the interloper: ready to run some more.

 

PROGRESS

Construction of Wheel Elements

Integration of Ultrasonic Ranger

Code Configuration

 

SCHEMATIC    (click schematic for higher resolution diagram)

 

 

ARDUINO CODE


#include &amp;amp;lt;NewPing.h&amp;amp;gt;

int TRIGGER_PINleft = 4 ;

int TRIGGER_PINright = 7 ;

int ECHO_PINleft = 5 &amp;amp;nbsp;;

int ECHO_PINright = 6 ;

int MAX_DISTANCE=55;

int wheel_left= 9;

int wheel_right=11;

NewPing sonarleft(TRIGGER_PINleft, ECHO_PINleft, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

NewPing sonarright(TRIGGER_PINright, ECHO_PINright, MAX_DISTANCE);

void setup() {

Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.

}

void loop() {

delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.

int leftread=(sonarleft.ping_cm());

int rightread= (sonarright.ping_cm());

// Serial.print("Pingleft: ");

// Serial.print(leftread); // Send ping, get distance in cm and print result (0 = outside set distance range)

// Serial.print("cm &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;");

// Serial.print("Pingright: ");

// Serial.print(rightread); // Send ping, get distance in cm and print result (0 = outside set distance range)

// Serial.println("cm");

int motorright=(1023-(rightread*16.24))*.75;

int motorleft=(1023-(leftread*16.24))*.75;

if (rightread!=0 &amp;amp;&amp;amp; rightread&amp;amp;lt;40){

analogWrite(wheel_right,motorright);

Serial.print("Pingleft: ");

Serial.print(leftread); // Send ping, get distance in cm and print result (0 = outside set distance range)

Serial.print("cm      ");

Serial.print(" Pingright: ");

Serial.print(rightread); // Send ping, get distance in cm and print result (0 = outside set distance range)

Serial.print("cm");

Serial.print(" motorright: ");

Serial.println(motorright);

}

else{

analogWrite(wheel_right,0);}

if (leftread!=0 &amp;&amp; leftread&amp;amp&lt;40){

analogWrite(wheel_left,motorleft);

Serial.print("Pingleft: ");

Serial.print(leftread); // Send ping, get distance in cm and print result (0 = outside set distance range)

Serial.print("cm &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;");

Serial.print(" Pingright: ");

Serial.print(rightread); // Send ping, get distance in cm and print result (0 = outside set distance range)

Serial.print("cm");

Serial.print(" motorleft: ");

Serial.println(motorleft);

}

else{

analogWrite(wheel_left,0);

}


delay(100);

}

 

PROCESS & OUTCOME DISCUSSION

The idea for the ShyBot came from an idea of interactivity.  During the sessions where we brainstormed different surprising things we could create, we devised many possibilities including a balloon popping machine, a automatic water gun, and a walking box.  Due to the physical limitations of the devices we had at the time and the interesting complexity that comes with movement, we decided to create a moving robot.  Through more deliberation, we decided that the most surprising thing a moving robot could do would be to move when you don’t expect it to and, with the amount of friendly, human-centric robots being made, to have it run away from people.  A large part of this decision was the limitations we had on devices available.  For example, some quick hand calculations showed that the servo motors in the physical computing laboratory, likely wouldn’t have enough force to cause a spray bottle to spray sufficiently far.

To create our shy robot, we tested many different sensing and movement related devices.  We learned how devices worked theoretically and how to use them.  This included infrared proximity sensors, visible light proximity sensors, photoresistors, servo motors, and, what we finally decided to use, ultrasonic rangers and DC motors with transistors.

Not only did using these devices teach us how they worked, but also general ideas about physical computing such as a better understanding of how pulse width modulation can be used to control things and how to convert the PWM into different voltages when using a transistor to control another circuit.  We also gained significant knowledge on using external power supplies.

We were really impressed with our final ShyBot prototype, but there were areas that we overlooked.  Throughout the design and building process, we focused on function over form.  This lead to the creation of an effective, but not particularly impressive looking robot.  When presenting to the class, it was noted how having a face on the front and the ultrasonic rangers more hidden behind the cardboard box could make it more approachable and more likely to surprise someone.  This was a very good point, especially when creating something that is meant to interact with people: the design should coincide with the function to foster a more natural interaction that leads to the intended purpose.

Also, there were some problems with noise from the ultrasonic rangers.  We implemented some simple filtering techniques including a low-pass cutoff, but with more time we would have explored different types of filters and the theory behind them.  Given enough time, we might have even created our own filter that was built for our purposes.


 

SaveSave

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-shy-box/feed/ 0
Surprise: Box https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-box/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-box/#respond Mon, 12 Feb 2018 01:17:11 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2592

The Box in its steady state.

Description:

The Box has two light switches on the front, and two sets of four LEDs on the top. When the user flicks the right switch on, all LEDs turn on. When the user flicks the same switch off, both lights turn off. When the user flicks the left switch on, the Box starts to beep faster and faster. When that switch is turned off, the Box stops beeping. Flipping the same switch on resumes the beeping. After the beeping flatlines, a side panel will open on the left side of the Box and the user can grab the candy inside the Box.

The Box when the right switch is flipped on.

Progress 1: Initial assembly of circuit on large breadboard, using small LEDs. The decision of which switch and which lights to use was yet to be made.

Progress 2: The circuits were moved to a smaller breadboard, LEDs, switches, and servomotor were attached to the interior of the Box, and the Arduino and breadboard were fit into the Box (first generation Box was ill fitting and not pictured).

Progress 3: The speaker was attached to the lid and everything else was stuffed inside the Box with the two batteries; one for the Arduino and one for the LEDs.

We decided the most efficient way to stabilize the LEDs and their wires was to use electrical tape rather than solder.

 

Schematic of both circuits used in the Box

Code:

#include <Servo.h>;
Servo myMotor;

int piezoPin = 8;
int servoPin = 3;
int interval = 100;
int switchPin = 7;
int delayTime1 = 1000;
int delayTime2 = delayTime1;
int play = 0;
int frequency = 2000;
int quiet = 500;
int waitTime = 10000;

void setup() {
myMotor.attach(servoPin);
Serial.begin(9600);
}

void loop() {
int switchVal = digitalRead(switchPin);
//decreases interval between beeps and resets # of plays
if (switchVal == 1 &amp;&amp; delayTime2 &gt; 50 &amp;&amp; play == 4){
delayTime2 -= 100;
play = 0;
}

//beeping
if (switchVal == 1 &amp;&amp; play != quiet){
/*Tone needs 2 arguments, but can take three
1) Pin#
2) Frequency - this is in hertz (cycles per second) which determines the pitch of the noise made
3) Duration - how long teh tone plays
*/
tone(piezoPin, frequency, interval);
delay(delayTime2);
play++;
}

//move motor when done beeping
if (play == quiet){
myMotor.write(90);
//wait a little so that the user can take the prize
delay(waitTime);
//reset parameters
delayTime2 = delayTime1;
play = 0;
myMotor.write(175);
}

Serial.print(play);
Serial.print(" ");
Serial.println(delayTime2);
}

Discussion:

Overall as a team we had little prior experience working with circuits so it was a great learning experience to create a full system from scratch. The hardest part was determining with our current knowledge what components we could use to achieve the aesthetic and goals that we wanted with our product. We tried for instance to use mini light bulbs instead of LEDs but could not figure out how to wire them properly. We also tried to use large toggle switches but instead switched to the smaller switches in order to use components that we knew how to wire. These decisions were largely made due to our inexperience working with larger components so we decided to stay with things we had worked with before. Another difficult part was the creation of the laser cut box and the trap door. It was difficult because we taped the servo motor to the wall of the box and glued the rotor to the door. This led to alignment issues when the door would open. From this we learned to properly plan and spec out everything before building it. This would have made fitting the components, from the servo to the switches, easier to the laser cut pieces.

We had little trouble once we determined the final components we were using in both the creation of the circuit and the coding. All of the logic was relatively simple in our operation and we just had to make little changes to things such as the frequency of the beeps. Looking back we could have changed the code in order to account for different user cases in how people could potentially interact with our box. As we had it set up, one switch powered the LEDs while the other switch triggered the noises as well as the trap door. What we should have done was make the first switch hit power the lights then the second switch trigger the noises/trap door. This would have led to the correct order of events happening no matter what thus setting up the overall surprise better. Overall this project was a great introduction to making an electro-mechanical system. We were able to see the importance of everything from using the right electrical components, to creating a sound mechanical system, and accounting for multiple usage cases in our code.

 

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-box/feed/ 0
Surprise: Fish Tank! https://courses.ideate.cmu.edu/60-223/s2018/work/project-1-fish-tank-surprise/ https://courses.ideate.cmu.edu/60-223/s2018/work/project-1-fish-tank-surprise/#respond Mon, 12 Feb 2018 00:44:52 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2463

Our interactive Fish Tank is a small aquarium with a jump scare. On the right side of the tank is a white cup labeledfish food”. When the user picks up this cup and empties the food into the top of the tank, a shark jumps up to eat the green fish and a small red LED lights up to indicate danger to the user.

 

The user feeds the fish.

Perspective view of the surprise!

Action shot of the shark! + LED

 

Close up of the fish food to demonstrate usability.

Schematic:

Code:


#include <Servo.h>

Servo motor_large;
Servo motor_1;
Servo motor_2;
Servo motor_3;

void setup() {
motor_large.attach(3);
motor_1.attach(5);
motor_2.attach(6);
motor_3.attach(9);
pinMode(A5, INPUT);
pinMode(10, OUTPUT);
motor_1.write(100);
motor_2.write(100);
motor_3.write(180);
motor_large.write(30);
Serial.begin(9600);
}

void loop() {
int photoVal = 0;
photoVal = analogRead(A5);
Serial.print("photoVal = ");
Serial.println(photoVal);
motor_1.write(100);
motor_2.write(130);
motor_3.write(180);
delay(1000);
motor_1.write(135);
motor_2.write(165);
if (photoVal <= 400) {
motor_large.write(135);
digitalWrite(10, HIGH);
}
else
{
digitalWrite(10, LOW);
motor_3.write(140);
motor_large.write(30);
}
delay(1000);
}

Overall, the intended user reaction in class was close to what we originally hoped for, although several features of our project differed from our initial ideas. The largest change during the creation process was the use of sensors – we first set out to use an ultrasonic sensor to trigger the shark when the user came close to the fish tank (placed where the “Feed the Fish” sign currently is) , but after realizing that the feedback from this sensor was not reliable, we came up with the idea of using a photocell sensor placed underneath the fish food cup with a timer delay. Another hiccup we had was that we were only able to power our project using a computer, rather than a bench supply or battery. We believe that the problem might’ve been spurred by using Serial statements in our code, or by not having all the grounds synced up together. Since we were pressed for time, we could not address this issue and continued to power the project using a laptop. One thing that we would probably change in the current state of the project is adding a cutout in the back of the board to easily access the breadboard and wires, since currently we have to reach down the inside of the fish tank which is not very efficient or easy to do. During the building process, we made sure to be precise in our measurements of cutting the board and placing the Arduino/breadboard/servos, which was very helpful in the overall organization of our project. Additionally, we focused on making the different parts of our setup aesthetically pleasing, which contributed to the user reaction/satisfaction with our project.

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/project-1-fish-tank-surprise/feed/ 0
Surprise: Music Lamp https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-music-lamp/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-music-lamp/#respond Sun, 11 Feb 2018 23:13:11 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2570 Images of Final Project

Description

The Music Lamp is a seemingly normal lamp, but with a hidden ability to play sounds as our aspect of surprise for this project.   The box is wired with a hidden switch in the back that controls whether the box will light up or play music. In one mode, the light will turn on and off with the switch on the front, and in the other mode, the switch will turn the music on and off. We decided to play the mario sound track, but with a simple change of codes, we can allow it to play other songs.  The box itself is made out of plywood and was cut using the laser cutter.

Progress Images

Our initial circuity on how to control a 12v LED Panel

 

Our final circuitry before assembling it into a box. The components that are controlled by the Arduino is a Piezo Buzzer to play music, a switch to switch between modes, a switch to turn ON/OFF, and the LED Panel to represent a lamp.

 

The box after being assembled. The box is made out of plywood, and each face was cut using a laser cutter. We then assembled it together using wood glue.

 

Schematic

Code


//code for Mario song taken from https://www.princetronics.com/supermariothemesong/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978

#define melodyPin 9
//Mario main theme melody
int melody[] = {
NOTE_E7, NOTE_E7, 0, NOTE_E7,
0, NOTE_C7, NOTE_E7, 0,
NOTE_G7, 0, 0, 0,
NOTE_G6, 0, 0, 0,

NOTE_C7, 0, 0, NOTE_G6,
0, 0, NOTE_E6, 0,
0, NOTE_A6, 0, NOTE_B6,
0, NOTE_AS6, NOTE_A6, 0,

NOTE_G6, NOTE_E7, NOTE_G7,
NOTE_A7, 0, NOTE_F7, NOTE_G7,
0, NOTE_E7, 0, NOTE_C7,
NOTE_D7, NOTE_B6, 0, 0,

NOTE_C7, 0, 0, NOTE_G6,
0, 0, NOTE_E6, 0,
0, NOTE_A6, 0, NOTE_B6,
0, NOTE_AS6, NOTE_A6, 0,

NOTE_G6, NOTE_E7, NOTE_G7,
NOTE_A7, 0, NOTE_F7, NOTE_G7,
0, NOTE_E7, 0, NOTE_C7,
NOTE_D7, NOTE_B6, 0, 0
};
//Mario main them tempo
int tempo[] = {
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

9, 9, 9,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

9, 9, 9,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
};
//Underworld melody
int underworld_melody[] = {
NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,
NOTE_AS3, NOTE_AS4, 0,
0,
NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,
NOTE_AS3, NOTE_AS4, 0,
0,
NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4,
NOTE_DS3, NOTE_DS4, 0,
0,
NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4,
NOTE_DS3, NOTE_DS4, 0,
0, NOTE_DS4, NOTE_CS4, NOTE_D4,
NOTE_CS4, NOTE_DS4,
NOTE_DS4, NOTE_GS3,
NOTE_G3, NOTE_CS4,
NOTE_C4, NOTE_FS4, NOTE_F4, NOTE_E3, NOTE_AS4, NOTE_A4,
NOTE_GS4, NOTE_DS4, NOTE_B3,
NOTE_AS3, NOTE_A3, NOTE_GS3,
0, 0, 0
};
//Underwolrd tempo
int underworld_tempo[] = {
12, 12, 12, 12,
12, 12, 6,
3,
12, 12, 12, 12,
12, 12, 6,
3,
12, 12, 12, 12,
12, 12, 6,
3,
12, 12, 12, 12,
12, 12, 6,
6, 18, 18, 18,
6, 6,
6, 6,
6, 6,
18, 18, 18, 18, 18, 18,
10, 10, 10,
10, 10, 10,
3, 3, 3
};

int song = 0;

void sing(int s) {
// iterate over the notes of the melody:
song = s;
if (song == 2) {
Serial.println(" 'Underworld Theme'");
int size = sizeof(underworld_melody) / sizeof(int);
for (int thisNote = 0; thisNote &lt; size; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / underworld_tempo[thisNote];

buzz(melodyPin, underworld_melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// stop the tone playing:
buzz(melodyPin, 0, noteDuration);

}

} else {

Serial.println(" 'Mario Theme'");
int size = sizeof(melody) / sizeof(int);
for (int thisNote = 0; thisNote &lt; size; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / tempo[thisNote];

buzz(melodyPin, melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// stop the tone playing:
buzz(melodyPin, 0, noteDuration);

}
}
}

void buzz(int targetPin, long frequency, long length) {
digitalWrite(13, HIGH);
long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions
//// 1 second's worth of microseconds, divided by the frequency, then split in half since
//// there are two phases to each cycle
long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing
//// multiply frequency, which is really cycles per second, by the number of seconds to
//// get the total number of cycles to produce
for (long i = 0; i &lt; numCycles; i++) { // for the calculated length of time...
digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram
delayMicroseconds(delayValue); // wait for the calculated delay value
digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram
delayMicroseconds(delayValue); // wait again or the calculated delay value
}
digitalWrite(13, LOW);

}

int buzzMode = 9;
int switchMode = 7;
int ledMode = 3;
int lightMode = 4;

void setup() {
pinMode(buzzMode, OUTPUT); //in series with a 100 ohm resistor
pinMode(switchMode, INPUT);
pinMode(ledMode, OUTPUT);
pinMode(lightMode, INPUT);
Serial.begin(9600);

}

void loop() {
int lightRead = 0;
int switchRead = 0;

switchRead = digitalRead(switchMode);
Serial.print("switchRead = ");
Serial.println(switchRead);

lightRead = digitalRead(lightMode);
Serial.print("lightRead = ");
Serial.println(lightRead);

if (switchRead == HIGH) { //light
noTone(buzzMode);
if (lightRead == HIGH) {
digitalWrite(ledMode, HIGH);
}
else {
digitalWrite(ledMode, LOW);
}
}
else { //sound mode
digitalWrite(ledMode, LOW);
if (lightRead == HIGH) {
Serial.println(" 'Mario Theme'");
int size = sizeof(melody) / sizeof(int);
for (int thisNote = 0; thisNote &lt; size; thisNote++) {
lightRead = digitalRead(lightMode);
switchRead = digitalRead(switchMode);
if (lightRead == LOW || switchRead == HIGH){
digitalWrite(buzzMode, LOW);
break;
}

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / tempo[thisNote];

buzz(melodyPin, melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// stop the tone playing:
buzz(melodyPin, 0, noteDuration);

}
}
else {
noTone(buzzMode);
}
}
}

Discussion

The project was relatively simple because each of the components (switches, buzzer, LED panel) were controlled separately by the Arduino, so conceptually the schematic is easy to understand. However, it was our first time using an external voltage source with an Arduino, so we accidentally wired 12 volts of electricity into the Arduino, which went up into Ryan’s computer, destroying it. This mishap taught us a very important lesson the hard way: to be very careful about how much power you are wiring into a circuit and to make two separate sides on the breadboard for different voltages. We also learned how to use a ULN2308 transistor to safely hook up high voltages (over five) with an Arduino. In retrospect, we could have tweaked the way we switched the different modes. For example, we could have used a random number generator in the code to arbitrarily switch between turning on the light or speaker. This would have changed the wiring since we would have only needed to wire one switch and would have also greatly changed the code. This tweak would allow the project to work without us having to flip the switch in the back, although it would have given us less control. Going forward, we would like to try to challenge ourselves with a more difficult software approach since our code was relatively simple for this project. Most of the code for switches and LEDs, we learned in class. The only other aspects we had to learn was how to use a piezo buzzer as well as how to import code (the mario sound track) and how to use those functions instead of just a simple digital write. We would also like to work on the visual and artistic aspect of projects since our project was made into a simple box and wasn’t the most aesthetically pleasing.

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-music-lamp/feed/ 0
Surprise: Mike’s noisy tail https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-mikes-noisy-tail/ https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-mikes-noisy-tail/#respond Sun, 11 Feb 2018 21:33:53 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2554 Images of Final Project:

Description:

Our Project for Surprise is a little creature we call Mike. Mike is a small mouse, and he copies sounds whenever a new tail is added to him. Each tail comes from a different animal, and Mike attempts to mimic how they sound. On occasion, Mike might may sound quite different. To add the tails, simply attach them to the black tail nob on Mike’s posterior. Mike will respond by making noise.

Progress Images:

This image shows how we initially made the circuitry outside the box. A larger breadboard was used for clarification, and we later switched to a smaller breadboard so it would fit in the body box.

This image shows how each resistor was soldered onto the male jack. The legs of the resistors were bent so the sleeve would still fit onto the jack, hiding the different resistors inside

This image shows our final circuitry displayed outside the box. A battery pack is used for powering the Arduino, and the male jack part is sticking out of the box, representing Mike’s tail.

Schematic:

Code:


//Reference: Adafruit Animal - Sound testing module
// Arduino Mario Bros Tunes With Piezo Buzzer and PWM by Dipto Pratyaksa

#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978

#define melodyPin 3
//Mario main theme melody
int mario[] = {
NOTE_E7, NOTE_E7, 0, NOTE_E7,
0, NOTE_C7, NOTE_E7, 0,
NOTE_G7, 0, 0, 0,
NOTE_G6, 0, 0, 0,

NOTE_C7, 0, 0, NOTE_G6,
0, 0, NOTE_E6, 0,
0, NOTE_A6, 0, NOTE_B6,
0, NOTE_AS6, NOTE_A6, 0,

NOTE_G6, NOTE_E7, NOTE_G7,
NOTE_A7, 0, NOTE_F7, NOTE_G7,
0, NOTE_E7, 0, NOTE_C7,
NOTE_D7, NOTE_B6, 0, 0,

NOTE_C7, 0, 0, NOTE_G6,
0, 0, NOTE_E6, 0,
0, NOTE_A6, 0, NOTE_B6,
0, NOTE_AS6, NOTE_A6, 0,

NOTE_G6, NOTE_E7, NOTE_G7,
NOTE_A7, 0, NOTE_F7, NOTE_G7,
0, NOTE_E7, 0, NOTE_C7,
NOTE_D7, NOTE_B6, 0, 0
};

//Mario main theme tempo
int mariot[] = {
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

9, 9, 9,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,

9, 9, 9,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
};


void setup(void) {
pinMode(A0, INPUT);
pinMode(3, OUTPUT);
Serial.begin(9600);
// put your setup code here, to run once:

}

void loop() {
int resistance = analogRead(A0);
Serial.println(resistance);
if (958 <= resistance && resistance <= 964) //220 ohms
{
sing(1);
}
else if (948 <= resistance && resistance <= 954) //330 ohms
{
chirp();
delay(1000);
}
else if (938 <= resistance && resistance <= 944) //470 ohms
{
meow();
delay(1000);
}
else if (920 <= resistance && resistance <= 926) //680 ohms
{
dolphin();
delay(1000);
dolphin();
delay(500);
}
else if (895 <= resistance && resistance <= 903) //1000 ohms
{
animal();
delay(1000);
}
}

int song = 0;

void sing(int s) {
// iterate over the notes of the melody:
song = s;
int size = sizeof(mario) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {
int noteDuration = 1000 / mariot[thisNote];
buzz(melodyPin, mario[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
buzz(melodyPin, 0, noteDuration);
}
}

void chirp() { // Bird chirp
for (uint8_t i = 200; i > 180; i--)
playTone(i, 9);
}

void meow() { // cat meow (emphasis ow "me")
uint16_t i;
playTone(394, 100); // "eee" (long)
for (i = 200; i < 400; i += 3) // vary "ooo" down
playTone(i, 10);
}

void dolphin() {
uint16_t i;
for (i = 1000; i < 1200; i += 4)
playTone(i, 3);
playTone(1664, 150);
playTone(12200, 70);
}

void animal() {
uint16_t i;
Serial.println("animal");
for (i = random(400,600); i > 300; i -= 3)
playTone(i, 15);
}

void playTone(uint16_t tone1, uint16_t duration) {
if (tone1 < 50 || tone1 > 15000) return; // these do not play on a piezo
for (long i = 0; i < duration * 1000L; i += tone1 * 2) {
digitalWrite(3, HIGH);
delayMicroseconds(tone1);
digitalWrite(3, LOW);
delayMicroseconds(tone1);
}
}

void buzz(int targetPin, long frequency, long length) {
long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions
//// 1 second's worth of microseconds, divided by the frequency, then split in half since
//// there are two phases to each cycle
long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing
//// multiply frequency, which is really cycles per second, by the number of seconds to
//// get the total number of cycles to produce
for (long i = 0; i < numCycles; i++) { // for the calculated length of time...
digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram
delayMicroseconds(delayValue); // wait for the calculated delay value
digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram
delayMicroseconds(delayValue); // wait again or the calculated delay value
}
}


Discussion for progress and outcome:

The surprise Project was a bit tricky, because we first had to discuss and consider what the elements of surprise consist them. We focused on unexpected stimuli or the breaking of an expected pattern, as the source of the surprise we would utilize. We wanted to consider which parts could cause a sensation of surprise, and a sound producing element seemed to be the best way to do so. As far as outward design goes, the goal was something endearing, and easy to trust. Initially, the use of a face that produces noise was considered, but then we fiddled with a box, and we that a 3-dimensional entity would be far more interesting. This design leap was essentially the most difficult part of the project, because our technical design and creativity was limited by creation of parts which would operate with a face, while remaining user friendly. Becoming comfortable with accessing a variety of different items in the IDEATE workspace was an important part of our progress; we initially stagnated because we did not have the confidence to go forward from schematics. Moving forward, sharper, and more detail oriented design is an important area for future improvement.

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/surprise-mikes-noisy-tail/feed/ 0
Surprise: The Friendly Box https://courses.ideate.cmu.edu/60-223/s2018/work/the-friendly-box/ https://courses.ideate.cmu.edu/60-223/s2018/work/the-friendly-box/#respond Fri, 09 Feb 2018 21:32:36 +0000 https://courses.ideate.cmu.edu/60-223/s2018/work/?p=2473 Check out the video at: Video_Friendly

The Friendly Box

 

What does it do?

The Friendly box is a box that loves waving at people. Walk up close to it and it will wave at you, accompanied by a piece of happy music.

 

What’s required?

  • LED’s (5)
  • Ultrasonic ranger
  • Hobby servo motor
  • Speaker
  • Wires/Jumper wires
  • 9V Battery
  • Supplies to make the box (cardboard/wood….whatever you choose)

 

Schematic

 

Code Documentation here

How?

The eyes of the box (ultrasonic ranger) are programmed to look for an object within 30cm distance. When the ranger does not find any object in front of it, the LED’s are programmed to run a ‘scanning’ pattern.

When the ranger finds someone in the range, the LED’s look like they are loading. After a few seconds (a random number of loads), a hand comes out of the box to wave at the person standing in front of it. This is done by sticking a hand onto the horn of a servo motor. The box also plays a piece of happy music through a speaker.

 

In the works….

 

Done!

Detail of the servo motor (hand)

 

 

Looking back….

We initially wanted to launch a ping-pong ball instead of the hand. We thought of doing this using a mechanical contraption using springs (see below image). However, getting the servos to keep the springs down under tension proved to be very difficult. This made us iterate the idea to include the hand.

]]>
https://courses.ideate.cmu.edu/60-223/s2018/work/the-friendly-box/feed/ 0