Ani_Thaumatrope!

Thaumatrope_faceThaumatrope_toast

It’s always lovely to be old school. It’s a thaumatrope about one happy human being having peanut butter toast. But I drew the toast on the wrong part so it’s like it’s already in someone’s throat. Still, it’s a lovely way to die by choking to dead/killed by food.

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…)

PComp_3_SuperMarioTime

During the PComp Lab_03, although as struggling as usual, I found it very enjoyable to make the speaker speak! Such a lovely moment, probably as exciting as finding the existence of fire. And I even made a short Super Mario music, sweet!

PComp_Lab_MarioTime! from JHCLaura on Vimeo.

But I found it really difficult, when me and Billy tried to adjust the volume of speaker and also to make chords(two tunes speak at the same time).

For the volume

#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;

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

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

void loop() {

  int buttonState = digitalRead(2);
  volumeAnalogValue = analogRead(potenPinNum);

  volume = map(volumeAnalogValue, 0, 1023, 0, 490);
  Serial.println(volume);

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

  lastButtonState = buttonState;

  if (switchIsOn == true) {

    analogWrite(speakerPinNum, volume);
    Serial.println(volume);

    for (int i=0; i<2; i++) {
      int noteRead = analogRead(i);

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

My original idea was

  1. connecting speaker to digital pin #8, and potentiometer to analog pin #A5
  2. mapping the analogInput from  0~1023 to 0~490, setting it as volume
  3. analogWrite it into pin #8

But it failed  :/

Luckily, I bumped into my 2nd year buddy Andy and bothered him a couple of minutes and his advice simply blown my mind. He suggested using the potentiometer directly between digital pin #8 and the speaker, and adjust it directly without writing any codes! Wow. How I’ve never thought about this? And it worked! It simply proved that I’ve not thought it through totally. Hmmmm so much work to do, fighting 🙂

VolumeAdjust

New codes!

#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;

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

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

}

void loop() {

  int buttonState = digitalRead(2);
  volumeAnalogValue = analogRead(potenPinNum);

  volume = map(volumeAnalogValue, 0, 1023, 0, 490);
  Serial.println(volume);

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

  lastButtonState = buttonState;

  if (switchIsOn == true) {

    for (int i=0; i<2; i++) {
      int noteRead = analogRead(i);
      Serial.println(noteRead);
      if(noteRead > threshold) {
        tone(speakerPinNum, note[i], noteDuration);
      }
    }
  }
}