Wednesday, October 17, 2012

Arduino + Processing: first go.

THE CODE:


//CCLab Home work week_07
//Cupcake & Strawberry - array - radius - oscillation of an object - mouse
//Processing + Arduino

//new tab
PImage straw1 /*straw2*/;
// array -  first give it a name then a legnth
ArrayList Strawberry;

//Arduino button
import processing.serial.*;
import cc.arduino.*;
int pin = 5;
Arduino arduino;

int sensorValue;

void setup() {
  smooth();
  size(600, 600);
  
  arduino = new Arduino(this, Arduino.list()[0], 57600);
  noFill();
  noStroke();
  for (int i = 0; i <= 13; i++){
  arduino.pinMode(i, Arduino.INPUT);
 }
  
  //initialize first step
 Strawberry = new ArrayList();
 Strawberry.add(new Strawberry(width/2, height/2));

  straw1 = loadImage("straw1.png");
  //straw2 = loadImage("straw2.png");
    
}

void draw() {
  background(255);
  
  //Arduino button
  if (arduino.digitalRead(pin) == Arduino.HIGH){
     Strawberry.add(new Strawberry(mouseX, mouseY));
     
}
    else { 
      fill(0);
      noStroke();
    }
  
PImage myImage = loadImage("cake.png");
imageMode(CENTER);
image(myImage, width/2, height/2);

//I'm going to have a array of strawberry
 for(int i = 0; i < Strawberry.size(); i ++){
   Strawberry myStrawberry = (Strawberry) Strawberry.get(i);
   //this where you put it
   //draw the array
   myStrawberry.move();
   myStrawberry.display();
  
 }
   
//ellipse(280, 240, arduino.analogRead(pin), arduino.analogRead(pin));
  
    println(arduino.digitalRead(pin));
    
}

 /*void mousePressed(){
 Strawberry.add(new Strawberry(mouseX, mouseY));
 //telling what to do - add - calling the contucttor
 }*/

THE CLASS CODE:

class Strawberry {
  //Strawberry images
  PImage straw1 /*straw2*/;
  //color c;
  float xPos;
  float yPos;
  float ySpeed; //speed up and down
  float acc; //gathering speed

  Strawberry(float tempX, float tempY) { //same as class
  //strawberry(float tempYSpeed) { //feeding my donut //to make 1 a different speed
  straw1 = loadImage("straw1.png");
  //straw2 = loadImage("straw2.png");
  


    //c = color(0, 0, 0);
    xPos = random(0, width);
    yPos = height/2;
    ySpeed = 2; //tempYSpeed// take away the # value to change the speed
    acc = random(0.05, 0.3);
  }

  void display() { //can add aggument to change the color
    noStroke();//

   image(straw1, xPos, yPos, 100, 100);
   //image(straw2, xPos, yPos, 50, 50);

    }

  void move() {
    ySpeed += acc;
    yPos += ySpeed;
    
    if ((yPos >= height) || (yPos == 0)) {
      ySpeed *= -1;
      
     
      
    }
  }
}


Wednesday, October 10, 2012

Let There Be Code

Week01:
Get outside, get inspired and recreate a shape/object in Processing inspired by your time outside. This homework MUST use atleast one custom function, arrays and PImage and mouse interaction. Optionally use sin/cos and/or push and pop matrix. Share an image of what inspired you.

Week02:
Write your own class from scratch, give it some properties and functions. Make multiple objects of that class. Declare arguments in your class, and feed them values from the main code. Use Translate/push/pop matrix to make some interesting Interactions and tell a story. Advanced: Make an array of objects

Week03:
Create multiple objects using Arrays and have the objects interact with each other somehow - bounce, repulse etc. Add new objects upon mouse interaction. Make your objects interesting – not circles, rectangles squares. for eg. use PNGs.

Week04:
Use a library or multiple libraries to create an interesting audio-visual interaction with minimal or no use of mouse/keyboard. Using sin/cos and time will make your animations super interesting.

Week05:
Light two LEDs in your circuit. Incorporate Potentiometer or Push Button or another sensor for extra credit (extra fun!)

Two LED light will turn on when a button is pushed. Super simple and fun!


Week06:
Make a super fun interaction using sensors and objects
- think how you could make a simple instrument or capture a gesture, or embody an emotion
- make it meaningful
Use stuff we’ve learned so far – classes, libraries, sin/cos, so many things to work with!


STRAWBERRIES!!!!

To check out the CODE.

Stay tune for more fun stuff. Next on the ballot, XCode and OpenFrameworks.


Wednesday, October 3, 2012

Knights of Balls

I HEART "the Guild" like nobodies business!

The Guild

And since school, life, future, has been on my mind a lot and the six season of The Guild started this week I thought I'd share a funny .gif I found.


I to feel like I've got a lot to juggle. Literally.

Monday, October 1, 2012

I Need a Rosetta Stone for Code

Need a Job? You'd better learn code. *link
I do a lot of web-surfing, in fact I like to think of myself as a Pro Web-Surfer. It's kinda my thing! And I love it when I come across something that gets me jazzed about something-or-another about what I'm currently doing, what I want to do or that others are doing.

I really dig it when come across, what I call "the rhyme and reason" of things. What I mean is, when I land on something, a video, blog, write-up about a subject that I'm just getting into. For example, code. I'm just now learning this new language. I had experience with other code languages but I wasn't fluent.  I really didn't have a desire to be so. I just did the basic of code homework assignments, just what I understood. I never tried to push the boundaries of what code could do. I needed something to light the fire, a rhyme and/or reason. And what might you ask is that rhyme or reason? Why the best that there could be, a job. Yes I'm a little lame in that I'm letting the almighty job lead me. I'm going to need a job to pay for this education I'm getting and since this education is providing away to learn this "code" thing, I figure I might as well take advantage.

So bring on the code. Then a good job. Then paying off all my debt. Then retire on a mountain over looking a beach that has a huge city about 30 minutes away by car. The mountain is for my husband who wants a cabin on top of a mountain and the beach and city are for me.