PComp_UnoBurnedNO0oo…

Burned my arduino...

Inspired by the crazy servo motor workpiece by David Bowen, I tried to learned controlling DC motor rotating direction with H-bridge through this tutorial but failed to change the direction. The result was either rotated or stopped. Thinking the possibility of my motor might be broken, I borrowed other’s official stater kit’s DC motor, which was smaller than mine, and then things just went wrong…

The motor spun so fast and Uno became kind of warm. I pulled out the power supply but it was too late. I couldn’t upload any sketches anymore. Even unplugged all the wires and run the Example sketch…. NOOO000ooo….

Too frustrated to take a pic of my breadboard. Should remember to avoid emotions stopping you document next time…

ICM_ToxiclibsTest_Mushroom

First attempt to use amazing library Toxiclibs, mushroom-like water creatures with big head and jumpy acts. Cursor is an attractor to pull them closer to each other. And it ends up with a beautiful mistake oops.

As you can see, the frame rate of it became super slow because I put addBehavior() in draw() instead of in setup(), or in the constructor of the class. If I didn’t have an office hour with Daniel Shiffman I’d never know! But after I rewrote my codes, having all of the adding-force stuff happen just once, my sketch became less interesting, as below.

 

Less violent and less organic : Still trying to figure out how to solve the problem –> Making the violent/organic/electric movement without dragging down the whole system.

Here’re the codes: v.1, v.2.

V&S_4_Reading_In the Blink of An Eye

First of all, as one-shot scene mentioned in the reading, here’s an one-shot scene I’d love to share, from movie Atonement by Joe Wright. I respect it more after filming by ourselves.

After this project, I find editing is much more easier than filming actually. Just like cooking, without good and fresh materials, you can’t make a cuisine. It helps a lot if you have all the materials you want on hand, thus the things like “in the middle of cooking finding that you don’t have onions at all and you either have to deal with it or just stop cooking and walking out to buy one” won’t happen on you.

There’re two points I find relatively interesting in the reading.

  • Like sleeping therapy, editor helps director to make description more clearly(when things don’t go as what director originally think about, director will defend for it then thus become more aware of the theme/thoughts). It’s so true. We’re both the directors and editors in this class project, and when we started editing, we kind of rethought about the whole concept and became more aware of the shots we missed.
  • Filming and editing are like learning foreign language. You know it well enough but it’s always difficult to speak or even write it. Sometimes you just have to let it go and speak whatever come across your mind, or you’ll be framed by the grammars and then stuck. And this happens in filming/editing as well. A lot of things didn’t follow the script at all. Storyboard and script become a big concept to follow, and improvisation gradually dominates all. But I’m not sure if it’s a good thing, because it seems professional movies and animations follow the script strictly. Some of the final shots look exactly the same with storyboard. That’s probably because they spend a lot of time in the pre-production and sometimes it takes years, so they can make sure what they really want clearly and then be able to follow the script. And maybe it’s also related to the scale. It costs hugely so you don’t have space to waste, and it needs clear descriptions for a lot of staff to follow. And it makes me wonder, is it normal and good to improvise in small scale production? For either filming or editing?

Below is my first editing work, and since it’s a fantasy told by reconstructing clips of movies, it’s relatively simpler than filming and editing at the same time.

PComp_5_Don’t Touch My Cookie!

Fantasy kind of comes to live guys!

After the PComp class, I was inspired to do more about how the communications between Arduino and Processing. I want them to be more instinct, more meaningful, and more related to each other, not just switching on and off. And stay away using MOUSE to control/adjust my work all the time. My works should have their own behaviors patterns, without others tell them what to do. (kind of like users can only have small control/impact on them ;))

So I came out of an idea to control the chocolate spiders amount of my this week’s ICM homework! Since my intention of this project is scaring away people who try to eat it, why not building the interaction based on that? The more you come closer to the cookie(I use photosensor), the more chocolate spiders will come out alive. And the button at Top Left corner will turn red to warn!PComp_cookie_spider

And it worked! 😀 The contends and the behavior matched perfectly. First time! Exciting!! And my circuit looked simple as well.

2013-10-09 14.33.07

Come out a good/crazy idea, and then execute it well in the most instinct and simplest way. It’s my goal of life now.

Below are my To-Do-Lists that inspired through today’s PComp class:

  1. Change velocity, acceleration, changes, instead of just position and on-and-off, so when there’s no input(no one using it), animation still runs.
  2. Different modes with different compositions of inputs. (e.g. Mode A: button 1; Mode B: button 1+2 …)
  3. Let users feel they control something in an abstract way. (Wwwwooo complicated…)

CookieSpider

HW_5_cookie

Choco spider cookie– lovely product that makes you scream on the second of you opening your mouth to give it a bite! Things is that, I felt extremely hungry recently and just couldn’t help eat up all the food around me, and if this cookie existed it would do me a huge favor.

For this assignment, I practiced the usage of ArrayList and PImage, and was more comfortable with PVector. And I’ve also learned about the function lerp() and velocity.heading() of PVector through the office hour with Daniel Shiffman! Below are some bloody difficulties I came across.

  1. Button functions!!! Arrhhhhh…. Use a lot of boolean to differentiate the mouse functions, e.g mousePressed() mouseDragged(), and mouseReleased(). Try and error…
  2. lerp() <– super useful!!
    • lerp(start, stop, amt) <– The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc.
  3. Don’t know how to make object of ArrayList interact with its fellows until the office hour w/ Dan. Just write two “for loop”s! One for itself, one for the others.
  4. In order to create the effect of animation, I tried using frameCount and it worked!
    • void grow() {
          if (frameCount % 14 == 1 && j<4) {
            legs.add(new Leg(0, 0, 20*cos(angle), 20*sin(angle)));
            angle += PI/6;
            j++;
          }
      
          if (j==4) {
            angle += PI/3;
            j++;
          }
      
          if (j>4) {
            if (frameCount % 14 == 1 && j<9) {
              legs.add(new Leg(0, 0, 20*cos(angle), 20*sin(angle)));
              angle += PI/6;
              j++;
            }
          }
        }
  5. Within PVector, you can use velocity.heading() to rotate object with its moving direction(check out Nature of Code!!!). That’s how I rotated my spiders and their traces. Combined with lerp(), my spider makes its slow U-turn in the beginning of birth.

But honestly, this time I was not thrilled about my work. Especially after I connected it whit Arduino. It worked, but I just didn’t feel it interesting enough. It’s really difficult to be creative, especially when you want to be. Maybe that’s because I was hungry that time….? It’s like you make a lot of efforts to give birth a baby, but in the end you find you don’t love he/she at all    :/

Anyway, below are the codes.

Continue reading

ICM_4_PatchBallsFlies

Here’s the combination of what I’ve learned so far from Learning Processing and The Nature of Code. I call it “Patch. Balls. and Flies”. It’s kind of messy but I’m glad all the interactions with each others work! Yah! Check it out(click click )!

Functions:
1) move patch to stop bouncing balls
2) press mouse to drag balls with patch
3) long-press keyboard to see flies clubbing!! B-)   (surprisingly fit this perfectly, the most EXCITING part, DANCING time!!)
4) let go keyboard(== keyReleased) to calm down the flies, and gather all the balls within the patch

(Forgive me the awful screen pics, can’t screenshot since this one involve functions of KEY.)

bouncing

clubbing_flies

reset

Here’s some struggles I’ve been through:

  1. when dragging balls, I calculated the distance with patch and ball, and then planed to add this fixed distance to the position of patch and set it as the position of balls. But since I wrote this code in void mouseDragged(), I recalculated the distance every time I dragged and that caused flickering. Thanks to the office hour w/ Daniel Shiffman, this calculation codes were moved into void mousePressed() and it worked!!! (tearing)
  2. same stupid things happened when I want to bump flies with balls: I forgot to set conditions and thus make flies be affected by every balls!
  3. Things getting complicated when I want to make the music band. In the end I successfully saved the original color, and changed the color once it’s been hit(hitGround == true &&  cubes.x < ball.x <cubes.x+w  && ball.y < (height-h)), and then restored the colors back later.

And codes time!

Continue reading

PComp_4_MusicInstrument

In PComp class Billy and I make a Music Instrument that can adjust the pitch by pressing and tapping. Check this out!

 

#include "pitches.h"

int lastButtonState = LOW;
boolean switchIsOn = false;

const int threshold = 10;
const int speakerPinNum = 8;
const int noteDuration = 20;

const int potenPinNum = 5;
int volumeAnalogValue = 0;
int volume = 0;

const int potPinNum = 2;
float saveNote;

int note[] = {
  NOTE_C4, NOTE_E4};

void setup() {
  Serial.begin(9600);
  saveNote = note[1];

}

void loop() {

  int buttonState = digitalRead(2);

  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      switchIsOn = !switchIsOn;
    }
  }

  lastButtonState = buttonState;

  if (switchIsOn == true) {

    int pitchRead = analogRead(0);
    int noteRead = analogRead(1);

    float pitch = map(pitchRead, 0, 950, 0, 100);

    if (pitch > 0) {
      note[1] += pitch;
    } 
    else {
      note[1] = saveNote;
    }

    Serial.print(pitch);
    Serial.print(" ");
    Serial.println(noteRead);

    if(noteRead > threshold) {
      tone(speakerPinNum, note[1], noteDuration);
    } 
  }
}

As for my review for this on Sunday, I made a basic music kit that you can control on/off, volumes, pitches(higher/lower), and tempo. But since it’s a single-note playing machine instead of templates/clip of music triggered one, it makes no difference with the changes of tempo.

MusicPractive

And thanks to almighty Moon! I got the idea of setting button-“released” as the command to adjust pitches, so that pitches won’t go crazy because of the unmeasurable amount/time of button-“pressed” when you press the button. Thank you Moon 😀

What I want to do next–

  1. make chords (office hour w/ resident booked!)
  2. play continuous clips instead of single notes
  3. be creative! not just pressing buttons… not interesting at all… go go go!

And here’s the code.

#include "pitches.h"

int lastButtonState = LOW;
boolean switchIsOn = false;

const int threshold = 600;
const int speakerPinNum = 8;
const int switchPinNum = 2;
const int higherPitchPinNum = 4;
const int lowerPitchPinNum = 3;

int pre_higherPitchRead = 0;
int pre_lowerPitchRead = 0;

const int tempoPinNum = 0;
const int noteGPinNum = 1;
const int noteEPinNum = 2;
const int noteCPinNum = 3;

const int noteDuration = 20;

int saveNote[3];
int note[] = {NOTE_C4, NOTE_E4, NOTE_G4};

void setup() {
  Serial.begin(9600);

  // save the original notes
  for (int i=0; i<3; i++) {
    saveNote[i] = note[i];
  }
}

void loop() {

  // on-off switch setting
  int buttonState = digitalRead(switchPinNum);
  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      switchIsOn = !switchIsOn;
    }
  }
  lastButtonState = buttonState;

  // read different notes
  int noteCRead = analogRead(noteCPinNum);
  int noteERead = analogRead(noteEPinNum);
  int noteGRead = analogRead(noteGPinNum);

  // set up duration of notes
  int tempoRead = analogRead(tempoPinNum);
  int tempo = map(tempoRead, 0, 1023, 5, 100);

  // press buttons to make notes go higher/lower 
  int higherPitchRead = digitalRead(higherPitchPinNum);
  int lowerPitchRead = digitalRead(lowerPitchPinNum);

  // when switch is on
  if (switchIsOn == true) {

    Serial.print(tempo);
    Serial.print("  ");

    // make notes go higher or lower
    for (int i=0; i<3; i++) {
      if (higherPitchRead == LOW && pre_higherPitchRead == HIGH) {
        note[i] *= 2;
      }
     if (lowerPitchRead == LOW && pre_lowerPitchRead == HIGH) {
        note[i] /= 2;
      }
      note[0] = constrain(note[0], 32, 4192);
      note[1] = constrain(note[1], 41, 5280);
      note[2] = constrain(note[2], 49, 6272);
    }

    // make sounds!
    if(noteCRead < threshold && noteERead < threshold && noteGRead < threshold) {
      for (int i=0; i<3; i++) {
        tone(speakerPinNum, note[i], tempo);
      }
    } else if(noteCRead < threshold && noteERead < threshold) {
      tone(speakerPinNum, note[0], tempo);
      tone(speakerPinNum, note[1], tempo);
    } else if(noteCRead < threshold && noteGRead < threshold) {
      tone(speakerPinNum, note[0], tempo);
      tone(speakerPinNum, note[2], tempo);
    } else if(noteGRead < threshold && noteERead < threshold) {
      tone(speakerPinNum, note[2], tempo);
      tone(speakerPinNum, note[3], tempo);
    } else if(noteCRead < threshold) {
      tone(speakerPinNum, note[0], tempo);
    } else if(noteERead < threshold) {
      tone(speakerPinNum, note[1], tempo);
    } else if(noteGRead < threshold) {
      tone(speakerPinNum, note[2], tempo);
    }

    Serial.print(note[0]);
    Serial.print(" ");
    Serial.print(note[1]);
    Serial.print(" ");
    Serial.print(note[2]);
    Serial.print(" ");
    Serial.println(" ");

  } else {
    for (int i=0; i<3; i++) {      // when swtich-off
      note[i] = saveNote[i];       // restore the original notes
    }
  }

  // remember the previouse higher/lower pitch buttons status
  pre_higherPitchRead = higherPitchRead;
  pre_lowerPitchRead = lowerPitchRead;
}

V&S_3_Reading_TheMachineStops

There’s an old Chinese saying– “Water can carry a boat; it can sink a boat”, and I think it can also describes technology perfectly. There’s no black-and-white judgement for technology, and in my opinion any innovation is neutral. It is human that makes the difference. For example, text message can be an excuse to avoid talking to someone(causing isolation), but at the same time it’s efficient to send quick and clear information(saving time). It all depends on how human use it.

But, I don’t mean that inventors don’t need to be aware of their doings. At least not in the vicious way. Inventors cannot control the usage of their invention by others, but at least they should, or try, to hold an intention to make this world better. Villains are not welcome to this world, sorry.