Updates from February, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    catherine 10:30 pm on February 7, 2011 Permalink | Reply  

    Lucy! 

     

     

    LUCY & SAM are noise making light sensitive bears! Lucy is my bear. Her sound is a little hard to detect because she’s just a young baby bear trying to find her voice.

    You can watch the video of Lucy & Sam here.

    You can view how Lucy works here.

     

     

     

     

     

     

     

     
  • Unknown's avatar

    Thom Hines 10:07 pm on February 7, 2011 Permalink | Reply  

    Light-Sensitive Noise Monster 

    http://vimeo.com/upload/video

    Working with the code we made last week to create different emotional gestures through sound, this week our task was to make creatures that responded to light using a photoresistor, either by loving light and hating dark, or hating light and loving dark. I partnered up with Bree Rubin to make two characters that were somewhat diametrically opposed. My creature is a predator of sorts that gets excited when darkness comes, as if that were the time it hunts. Bree’s creature is meant to be my creature’s natural prey, and so it fears the dark and loves the light.

    sound creature's lowly beginnings

    a monster in progress

    Another part of the assignment was that the light sensor wasn’t supposed to act as if it were a switch, but that changing light should affect it over time, in some sort of life-like way. Both of our creatures get happier or sadder based on their preferences, and these shifts happen over time. If it is light for a long time, my creature continues to get sadder and sadder. However, if there is an abrupt change in light levels, our creatures react in much stronger ways. For instance, if it is dark in the room but suddenly the lights come on bright, my creature will scream and very quickly be depressed. If, on the other hand, there is a lot of light and it suddenly gets dark, the creature will have a sudden burst of happiness and his mood will be shifted much quicker.

    Additionally, if either of our creatures are in their negative state for too long, they die, and can only be revived by making the room completely dark (in the predator’s case) or completely light (in the case of the prey).

    Here’s the code that runs the predator. The loop() handles all the logic and tracking of light levels and happiness and it runs various functions to indicate what emotion the speaker is supposed to convey.

    Also, here are my thoughtful written at the beginning of last class.

     
  • Unknown's avatar

    Yury Gitman 9:59 pm on February 7, 2011 Permalink | Reply  

    Toy Fair 2011 Feb: 13-16th 

    Image

     
  • Unknown's avatar

    minho 6:55 pm on February 7, 2011 Permalink | Reply  

    Charger scorpion 

    He has solar panel body and battery organs, charging by light. When he gets full charged, his poisonous tail emits light.

    Charging speed depends on power of light, brighter light charges it faster with reaction. He dies in dark.

    #define  v     18000
    #define  x     10000
    #define  z     8000
    #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  D     1680
    #define  E     1500
    #define  F     1350
    #define  G     1200
    #define  A     1050
    #define  B     912
    // Define a special note, ‘R’, to represent a rest
    #define  R     0

    // SETUP ============================================
    // Set up speaker on a PWM pin (digital 9, 10 or 11)
    int speakerOut = 9;
    // Do we want debugging on serial out? 1 for yes, 0 for no
    int DEBUG = 1;

    int photocellPin = 0;     // the cell and 10K pulldown are connected to a0
    int photocellReading;     // the analog reading from the sensor divider
    int LEDpin = 11;          // connect Red LED to pin 11 (PWM pin)
    int LEDbrightness;
    int growspeed;
    int bN = 0;
    int bNcount = 0;
    int bNcount2 = 0;

    void setup() {
    pinMode(speakerOut, OUTPUT);
    if (DEBUG) {
    Serial.begin(9600); // Set serial out if we want debugging
    }
    }

    // MELODY and TIMING  =======================================
    //  melody[] is an array of notes, accompanied by beats[],
    //  which sets each note’s relative length (higher #, longer note)
    int hellom[] = {c,  c};
    int beats[]  = {16, 64};
    int dyingm[] = {  v,  R, z, v };
    int beats2[] = { 200, 8, 8, 32 };
    int happym[] = {  c,  C,  g,  e,  C,  g,  z,  e,  z,    c,  C,  g,  f,  C,  g,  z,  f,  z,     c,  C,  g,  e,  C,  g,  z,  e,  z,     d,  e,  f,  z,  f,  g,  g,  z,  g,  a,  a,  z,  C,  R};
    int beats3[] = { 16, 16, 16,  16, 8,  8, 16, 16, 16,   16, 16, 16, 16,  8,  8, 16, 16, 16,    16, 16, 16,  16, 8,  8, 16, 16, 16,     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8, 16, 16};
    int sadm[]   = {z,  x,  z,  z,  x,  x};
    int beats4[] = {36, 36, 36, 36, 36, 200};
    int yesm[]   = {d, b, E};
    int beats5[] = {8, 16, 32};
    int nom[]    = {B,  B,  B,  B,  B,  B};
    int beats6[] = {8,  8,  8,  8,  8,  8};

    int MAX_COUNT = sizeof(hellom) / 2;
    int MAX_COUNT2 = sizeof(dyingm) / 2;
    int MAX_COUNT3 = sizeof(happym) / 2;
    int MAX_COUNT4 = sizeof(sadm) / 2;
    int MAX_COUNT5 = sizeof(yesm) / 2;
    int MAX_COUNT6 = sizeof(nom) / 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 tone1 = 0;
    int beat = 0;
    long duration  = 0;

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

    digitalWrite(speakerOut,HIGH);
    delayMicroseconds(tone1 / 2);

    // DOWN
    digitalWrite(speakerOut, LOW);
    delayMicroseconds(tone1 / 2);

    // Keep track of how long we pulsed
    elapsed_time += (tone1);
    }
    }
    else { // Rest beat; loop times delay
    for (int j = 0; j < rest_count; j++) { // See NOTE on rest_count
    delayMicroseconds(duration);
    }
    }
    }

    // LET THE WILD RUMPUS BEGIN =============================
    void loop() {
    // play each sound in order, with a pause between each one.
    photocellReading = analogRead(photocellPin);

    Serial.print(“Analog reading = “);
    Serial.println(photocellReading);
    Serial.println( growspeed);
    Serial.println(bNcount);
    Serial.println(bNcount2);

    LEDbrightness = 255;

    growspeed = map(photocellReading,0, 1023, 10000, 2000);

    if(photocellReading>300){
    bNcount2 = 0;
    bN = 0;
    bNcount = bNcount +1;
    if(bNcount == 4){
    bN= 2;
    }
    if(bNcount == 5){
    bN= 1 ;
    bNcount = 0;
    }

    }

    if(photocellReading<300){
    bNcount = 0;
    bN = 4;
    bNcount2 = bNcount2 +1;
    if(bNcount2 == 4){
    bN= 6;
    }
    if(bNcount2 == 5){
    bN= 5 ;
    bNcount2 = 0;
    }

    }

    switch (bN) {

    case 0:
    analogWrite(LEDpin, LOW);
    hello();
    break;

    case 1:

    analogWrite(LEDpin, LEDbrightness);
    happy();
    break;

    case 2:
    yes();
    break;

    case 3:
    // game4();
    break;

    case 4:
    analogWrite(LEDpin, LOW);
    no();
    break;

    case 5:
    analogWrite(LEDpin, LOW);
    dying();
    break;

    case 6:
    analogWrite(LEDpin, LOW);
    sad();

    break;

    }

    }

    void hello() {
    // Set up a counter to pull from melody[] and beats[]
    for (int i=0; i<MAX_COUNT; i++) {
    tone1 = hellom[i];
    beat = beats[i];

    duration = beat * tempo; // Set up timing

    playtone1();
    // A pause between notes…
    delayMicroseconds(pause);
    //noTone(speakerOut);

    }
    delay(growspeed);
    }

    void dying() {
    // Set up a counter to pull from melody[] and beats[]
    for (int i=0; i<MAX_COUNT2; i++) {
    tone1 = dyingm[i];
    beat = beats2[i];

    duration = beat * tempo; // Set up timing

    playtone1();
    // A pause between notes…
    delayMicroseconds(pause);
    //noTone(speakerOut);

    }
    delay(10000);
    }

    void happy() {
    // Set up a counter to pull from melody[] and beats[]
    for (int i=0; i<MAX_COUNT3; i++) {
    tone1 = happym[i];
    beat = beats3[i];

    duration = beat * tempo; // Set up timing

    playtone1();
    // A pause between notes…
    delayMicroseconds(pause);
    //noTone(speakerOut);

    }
    delay(8000);
    }

    void sad() {
    // Set up a counter to pull from melody[] and beats[]
    for (int i=0; i<MAX_COUNT4; i++) {
    tone1 = sadm[i];
    beat = beats4[i];

    duration = beat * tempo; // Set up timing

    playtone1();
    // A pause between notes…
    delayMicroseconds(pause);
    //noTone(speakerOut);

    }
    delay(2000);
    }

    void yes() {
    // Set up a counter to pull from melody[] and beats[]
    for (int i=0; i<MAX_COUNT5; i++) {
    tone1 = yesm[i];
    beat = beats5[i];

    duration = beat * tempo; // Set up timing

    playtone1();
    // A pause between notes…
    delayMicroseconds(pause);
    //noTone(speakerOut);

    }
    delay(growspeed);
    }

    void no() {
    // Set up a counter to pull from melody[] and beats[]
    for (int i=0; i<MAX_COUNT6; i++) {
    tone1 = nom[i];
    beat = beats6[i];

    duration = beat * tempo; // Set up timing

    playtone1();
    // A pause between notes…
    delayMicroseconds(pause);
    //noTone(speakerOut);

    }
    delay(2000);
    }

     
  • Unknown's avatar

    Lee 5:17 pm on February 7, 2011 Permalink | Reply  

    SPACE SQUID OF DOOOOOOM!!!! 

    So my Beep Boop creature is a squid. He loves the dark and hates the light. He’ll increasingly beep faster the longer he’s upset until he dies. He can be revived by being immersed in full darkness for a little while. He’ll get more excited the longer he’s in the dark.

    ::BONUS::When he’s upset his eyes will blink red as well.

    #include "pitches.h"    //list of the frequencies of most notes
    int counter=0;
    
    int photoPin=0;
    int speaker=6;
    
    
    //the reading must be bellow each of these values to ellicit that emotion
    int excitedPoint=120;
    int neutralPoint=180;
    //higher than neutral results in dying
    
    int reading;  //holds the current photo reading
    String state="neutral";
    
    //using resistor: gold, red, green, brown
    
    boolean dead=false;
    int reviveCounter=0;  //counts how logn the dead creature has been in darkness
    
    // These are for the LED eyes
    const int ledPin =  13;
    int ledState = LOW;             // ledState used to set the LED
    long previousMillis = 0; 
    long interval = 1000;
    
    void setup(){
      Serial.begin(9600);
      pinMode(ledPin, OUTPUT);
    }
    
    void loop(){
      noTone(speaker);
      //checks to see what state the creature is in
      reading=analogRead(photoPin);
    
      if (readingexcitedPoint &amp;&amp; readingneutralPoint &amp;&amp; state!="screaming"){
        counter=0;
        state="screaming";
      }
    
      //Deal with the various states
      //is it dead?
      if (dead){
        Serial.println("DEAD");
        if (random(100)==0)
          PlayDeathGasp();
        interval = random(100,1300);
        RedEye(interval);
    
        //if it is in darkness logn enough, it should revive
        if (reading100){
            Serial.println("CHECK IT");
            //wait a few seconds between playing bliss sound
            if (counter%200==0) {
              PlayBliss();
            }
          }
          else if (counter%20==0){
            //if not, keep upping counter and play the exciting 
            PlayExcited();
          }
        }
    
        if (state=="neutral"){
          if (counter==1){
            PlayNeutral();  //play the sound
          }
          //if it's been neutral for a while, make sure some time passes between making sounds
          //then play it randomly
          if (counter&gt;200){
            if (random(0,100)==0)
              counter=0;  //reset counter
          }
        }
    
        if (state=="screaming"){
          if (counter%20==0)
            PlayScream(); 
          interval = 500;
          RedEye(interval);
          if (counter&gt;100){
            PlayDying();
            dead=true;
          }
        }
      }
    
      Serial.println(state);
      counter++;
      Serial.println(analogRead(photoPin));
      //Serial.println(counter);
    }
    
    void PlayNeutral(){
      //neutral tone sare played in a series of two.
      int notes[]={ 
        NOTE_D4, NOTE_B3, NOTE_A3, NOTE_F3, NOTE_DS3, NOTE_CS3                  };
      int start=random(0,2) *2;
      for (int i=start; i&lt;start+2; i++){
        tone(speaker, notes[i]);
        delay(500);
        noTone(speaker);
        delay(300);
      }
    }
    
    //&quot;I'm bursting with joy!&quot;
    void PlayBliss(){
      //oscilate between two ranges that keep moving up
      //originaly 512
      int startVal=512;
      int endVal=860;
      int range=100;
      int val=startVal;
      int incr=random(1,3);
    
      while(val&lt;endVal){
        //send it up
        int tempMax=val+range;  //how far up to go with this pass
        for (val; valtempMin; val-=incr){
          tone(speaker, val);
          delay(3);
        }
      }
    
      //hold the last value for a little while
      delay(500);
    }
    
    void PlayScream(){
      int scream[] = {
        NOTE_B4, 0, NOTE_G4, 0, NOTE_E4, 0, NOTE_D4                  };
      int screamDurations[] = {
        4,16,4,16,4,16,1                  };
    
      for (int thisNote = 0; thisNote endVal; i--){
        tone(speaker, i);
        delay(6);
      }
    
      //now create two beeps.
      noTone(speaker);
      delay(200);
      tone(speaker, 300);
      delay(500);
      noTone(speaker);
      delay(200);
      tone(speaker, 200);
      delay(500);
    }
    
    void PlayExcited(){
      int levelAdjust=map(reading,0,excitedPoint, 300,0);
      int toneA=NOTE_B4+levelAdjust;
      int toneB=NOTE_G5+levelAdjust;
    
      int counterAdjust=map(counter,0,100,0,40);
    
      for (int i=0; iendVal; i-=30){
        tone(speaker,i);
        delay(30000/i);
      }
      noTone(speaker);
      delay(500);
    
      //a few little burbles
      for (int i=0; i&lt;3; i++){
        PlayDeathGasp();
      }
    }
    
    //Burbles and gurgles
    void PlayDeathGasp(){
      tone(speaker, random(50,70));
      delay(random(500,1000));
      noTone(speaker);
      delay(random(500,1000));
    }
    
    //&quot;I'm coming back to life!&quot;
    void PlayRevive(){
      int startVal=50;
      int endVal=NOTE_D5;
    
      for (int i=startVal; i&lt;endVal; i+=30){
        tone(speaker,i);
        delay(30000/i);
      }
      noTone(speaker);
      delay(500);
    
      for (int i=0; i interval) {
        // save the last time you blinked the LED 
        previousMillis = currentMillis;   
    
        // if the LED is off turn it on and vice-versa:
        if (ledState == LOW)
          ledState = HIGH;
        else
          ledState = LOW;
    
        // set the LED with the ledState of the variable:
        digitalWrite(ledPin, ledState);
      }
    }
    
     
  • Unknown's avatar

    Bree 11:40 am on February 7, 2011 Permalink | Reply  

    I shall call him “Meat” 

    This is Meat. He is a bit of a nervous thing and really gets upset when the lights dim. Turn them off too quickly, and he screams. If he freaks out too much, he’s going to pass out and only a quick burst of light can wake him up.

    Why is he afraid of the dark? Because there are monsters out there…

    Meat gets ready for his housingThese are Meat's insides

     

     

    How does his little mind work?

    With very messy code.

    ————————————————————————————-

    ————————————————————————————-

    // Dayturnal “meat”

    // int vars
    int speaker = 9;

    int lastlight = 0;
    int light;
    int mood = 100;
    boolean happy = true;
    boolean scared = false;

    int deathCounter;
    boolean dead = false;

    void setup() {
    // set up pins and serial
    pinMode(0, INPUT);
    pinMode(9, OUTPUT);
    Serial.begin(9600);
    }

    void loop() {

    // check light sensor
    light = analogRead(0)*10;
    // make sure that value checking changes in light is same as light on first run
    // otherwise, it could falsely register a big change in light
    if(lastlight == 0) lastlight = light;

    // send values to serial
    Serial.println(“light: “);
    Serial.println(light);
    Serial.println(“mood: “);
    Serial.println(mood);
    Serial.println();

    mood = map(light, 0, 1000, 0, 1000);
    // run most of the code unless creature is dead

    // lazarus function
    if(dead){
    if(light – lastlight > 200) {
    dead = false;
    deathCounter = 0;
    // preyRelief();
    mood = 100;
    lastlight = 120;

    }
    }

    if(!dead) {

    // happiness follows light level
    if (mood >= 80){
    happy = true;
    }
    if (mood < 80){
    happy = false;
    scared = true;
    }

    if(light > lastlight) {
    mood+=5;
    }
    else if(light < lastlight) {
    mood-=5;
    }

    // sudden drop in light, OH NO!
    if(lastlight – light > 100) {
    preyScream();
    mood = 1;
    scared = true;
    }
    // sudden burst of light, OH JOY!
    if(light – lastlight > 100) {
    preyRelief();
    mood = 200;
    happy = true;
    }

    // if too little light, creature starts dying
    if(light < 50) deathCounter++;
    // otherwise, creature is recovering
    else deathCounter–;

    // if too little light for too long, DEATH!
    if(deathCounter > 20) {
    preyScream();
    death();
    dead = true;
    }

    // play normal noise on each loop
    preyNoise();
    // use line below instead if you don’t want the flat-line noise
    // when creature dies.
    if(!dead) preyNoise();
    }

    // remember last light value to see changes over time
    lastlight = light;
    }

    // standard creature noise, dependent on mood level
    void preyNoise() {

    if(happy){
    int basetone   = map(mood, 0, 800, 150, 1000);
    int basetempo  = map(mood, 0, 800, 20, 600);

    //3 notes
    tone(speaker, basetone);
    delay(basetempo);
    noTone(speaker);
    delay(basetempo);

    tone(speaker, basetone*1.26);
    delay(basetempo);
    noTone(speaker);
    delay(basetempo );

    tone(speaker, basetone*1.5);
    delay(basetempo);
    noTone(speaker);
    delay(basetempo);
    delay(basetempo*2);
    }
    else if (scared){
    int basetone   = map(mood, 0, 800, 150, 1000);
    int basetempo  = map(mood, 0, 800, 10, 600);
    basetempo      = basetempo – mood;

    //3 notes scared
    tone(speaker, basetone);
    delay(basetempo);
    noTone(speaker);
    delay(basetempo / 5);

    tone(speaker, basetone);
    delay(basetempo);
    noTone(speaker);
    delay(basetempo / 5);

    tone(speaker, basetone*1.6);
    delay(basetempo);
    noTone(speaker);
    delay(basetempo / 5);
    delay(basetempo*2);

    }

    }

    // noise when too much light comes abruptly
    void preyScream() {
    int freq = 2100;
    for(int x=0; x < 3000; x++) {
    tone(speaker, freq);
    delay(2);
    if (freq < 2800){
    freq++;
    }
    else {
    freq=3000;
    }
    }
    }

    // noise when light comes back abruptly.
    void preyRelief() {

    }

    // sound which occurs when creature dies
    void death() {
    tone(speaker, 200);
    delay(40);

    }

     

     

    ————————————————————————————–

    ————————————————————————————–

     
  • Unknown's avatar

    andywallace 5:52 am on February 7, 2011 Permalink | Reply  

    Space Squid (With Lee Williams) 

    Lee and I created a pair of darkness loving space squids. They become very happy when placed in the dark, but become frightened by the light, and can even die from it.

    The space squid uses a photoresistor to sense light and a piezo speaker to make sound. The apparatus is contained inside a cardboard box with the image of a squid on the front. The squid has 5 states that it can be in:

    Excited – In low light, the squid becomes excited and will chirp. The chirp will be higher pitched the darker it is, and the longer it is excited, the chirps will become faster and faster.

    Bliss – If the squid is in low light long enough, and will become overwhelmed with joy and shout out.

    Neutral – In a space that is not quite dark, but not quite bright, the squid will just chirp every so often to let you know it’s there, but not much else. The sound played is a two tone sound chosen at random from several that Lee and I created to make the creature feel more organic.

    Screaming – In a brighter space, the squid will start screaming. The screams will get faster and faster as the squid becomes more urgent.

    Dead – If the squid is in the light for two long, it will die. After playing a death sound, it will let out a pathetic groan every so often. This groan is a somewhat randomly generated low tone.

    There is hope, though! If placed in darkness for a long enough time, the squid will regenerate and play a special melody showing that it has come back to life.

    The wiring before I put it in the box.

    And the box I used.

    I punched some holes for the speaker.

    I left the potentiometer attached to the piezo in case I wanted to adjust the volume.

    A diagram of the wiring made in Fritzing.

    CODE

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel