subscribe to my newsletter!
contact: geoffroy tremblay | gef@ponnuki.net | 514.303.2647

programming


k-12 presentation

June 19th, 2010 — 4:40pm

I know it’s been a month now that I haven’t blog! Too much is happening here – from wordpress moving to version 3, to my come back to school (in information technology) to all my project moving forward, and summer kicking in ~ there wasn’t much time left. I also prepared a introduction to processing and opensource technology for computational art for a k-12 school, and that was really fun, read more below!

Last week I went to do a presentation to a k-12 school here in Crawford Bay. Since I started learning processing I realized how helpful that could be for the new generation to learn an easy way to program. Learning processing (and programming in general) also merge all the mathematical knowledge you have, with a solid foundation in problem solving and computer usage. I feel that if programing was re-introduce in school, it should build on processing.

I started programming on vic-20 and never really wanted to learn programming language until I discovered Processing. So I tough that giving a presentation to a k12 school would be really interesting. Like many k-12 school in small villages, there is not many students, and keeping the school alive becomes quite a problem compare to urban schools. To remedy this, the director of the school, Dan Rude, and the teachers there decided to open up the doors for Mentors to come and help inspire the kids. I grabbed that opportunity to present Processing and Arduino, with a quick overview of pure:dyne and how can kids benefit from open source technologies.

I presented most of my project that I posted here on ponnuki, from the fish pond, to the spaceship game, to the video cam project to controling processing with a Nintendo DS (upcoming post about that) and creating a video animation with processing and using the arduino to do a laser show. I wanted to give an example of all the inputs that can be used in processing to give a solid foundation about all the possibilities that opens up when learning a programming language.

The video you see here is an integration of audio in processing using the minin library. As you can see the music is not too much in sync with the sketch ~ it’s probably due in part because of my computer power (yes I will get a more powerfull machine for your eyes pleasure in the spring) and also processing is not optimized for audio.

In the future for project that binds audio with visual I will research more about pureData feeding osc into processing, for that presentation I didn’t have much time to come up with something visually appealing. You can see that I added some Penrose system and snowflake (the green structure growing from the center), two example that are part of the main processing installation.

audio – processing integration from Geoffroy Tremblay on Vimeo.

It was great to see the kids enjoying the presentation, and I hope I will be able to mentor one or 2 of them in a video game/ multimedia creation next year! Meanwhile I continue my Processing quest!

3 comments » | arduino, processing, programming

video and processing

May 8th, 2010 — 6:24pm

I haven’t received my new video camera yet so I will have to delay the post about my audio mixer ~ so I decided to post some example of other project I am tinkering with. This is a small video project that I did in processing. This is only the output of the project. video processing screen shot

I am using an eyetoy – the web cam for the playstation2 that I got on ebay for 99c, and running the project on pure:dyne. In order to use video on processing in linux, you need to use an extra video library gsvideo. It’s a really great library that work really well and that is really fast. I read previously that video on processing in linux could be hard – but it is really easy and fun.

Here is the code ~ it’s created half randomly testing rotation, pop and push matrix,a dding some structures in 3d:

import codeanticode.gsvideo.*;
GSCapture cam;
float a = 0;                 // the variable used for the rotation

void setup() {
  size(800, 600,P3D);
  cam = new GSCapture(this, 320, 240);
}

void draw() {
 background(0);
 camera(-1000+mouseX*6, -1000+mouseY*6, 800, 90.0, 50.0, 0.0,  0.0, 1.0, 0.0);                   // camera controled by the mouse

  if (cam.available() == true) {
    cam.read();
    filter(DILATE);  //some test on filters - I wasn't too sucessful yet
    translate(320,240);

    pushMatrix();                  // here is the construction of the
    rotateY(a*PI);                  // video - a bit a random trying to create shape and mouvements
    image(cam, -320,-240,320,240);
    image(cam, 0,0,320,240);
    image(cam, 320,240,20,40);
    image(cam, -620,-340,80,70);
    image(cam, -320,-240,320,240);
    image(cam, -320,-240,320,240);
    image(cam, -320,-240,320,240);
    stroke(255,0,0);
    noFill();
    box(120);
    rotateX(PI/2);
    image(cam, -320,-240,320,240);

    for (int i = 0; i < mouseY/20;  i++){
      image(cam, random(0,(width-164)),random(0,(height-48)),64,48);
    }
    popMatrix();
    pushMatrix();

    rotateY(a*PI+PI/2);
    image(cam, -320,-240,320,240);
    rotateX(a*PI+PI/2);
    image(cam, -320,-240,320,240);
    rotate((-a));
    box(80);
    popMatrix();

    a = a+0.01;   // for the rotation
  }
}

And here is an output of the video. The movement is controled by the mouse

Comment » | processing, programming

2nd step DIY audio mixer processing & arduino

April 25th, 2010 — 6:12pm

I created my first prototype of the mixer. It’s more an experiment than a prototype from the fact that I only attached 6 knob to the arduino to start with.

Here are some picture of the making of the mixer. I used a normal plastic project box to do the trick, to give it some sort of finish to the product. Using hand drill and bee wax and my main tool (yeah I know really professional !) I glued the knob in place.

The main part of the experiment was to link the mixer to output to the computer. The first layer is the physical knob, then the arduino chip then processing. For the processing – arduino communication there is already a library. You can load a firmware in arduino (firmata) that helps the communication. Then in processing you can load the arduino library. By the way, the default library you can download from arduino site has an error. The library is named Arduino.jar, which gives you an error if you try to load it. You have to rename it arduino.jar, without the capital in order to make it work. (using pure:dyne I got an error renaming the file, I had to rename it to something else first then to arduino.jar – the file system assuming that Arduino and arduino is the same thing it wouldn’t let me rename the file!)

Here is where you can get more information about the arduino processing http://www.arduino.cc/playground/Interfacing/Processing. Make sure to rename the library in processing ~ there was a problem at first with the arduino library having a capital letter at the beginning…

Once that is installed properly I tried an example program and then modified it to my need. I wanted to have a visual that would translate a better more the knob feeling. It’s also a very simple example of popMAtrix and pushMatrix and rotate function. Here the push and popMatrix are used to prevent all the knob to be affected by each other rotation – while it was kind of fun to rotate the whole canvas!

import processing.serial.*;
import cc.arduino.*;

Arduino arduino; // new arduino object

void setup() {
  size(470, 280);
  smooth();
  arduino = new Arduino(this, Arduino.list()[0], 57600);

  for (int i = 0; i <= 13; i++)
 {
    arduino.pinMode(i, Arduino.INPUT);
 }

}

void draw() {
  background(0);
  stroke(255);
  strokeWeight(10);
  noFill();

  for (int i = 0; i <= 5; i++) {  //cycling trough the 6 analogue input

    pushMatrix();

    translate(60+i*70, height/2);
    rotate(arduino.analogRead(i)/30); // Rotating with the analogue in

    ellipse(0,0,60,60);   // Creating the knob
    line (0,0,0,30);

    popMatrix();

  }
}


Here is a simple video demo of the mixer in action, next step is to try it out with puredata just for the fun of it and soon will be the test with the USB64! The Doepfer usb64 seemed to be quite a challenge at first (I haven't done soldering for years - I think the last time I did I was around 12 !!) but I finally got a hang of it ! Stay tune for part 3 of the DIY usb audio mixer!

Comment » | arduino, music, processing, programming

processing ~ new spaceship game!

April 9th, 2010 — 5:37pm

This is my new processing self teaching project. In this project I wanted to built a mouse control spaceship that would shoot and crash if it reaches the celling or the floor. It’s not object oriented at all and the code is quite messy ~ and I won’t clean it up until I reuse to code in another project.

Again it’s not a complete game, just a learning tool or a proof of concept for a space shooter scrolling game. I was happy to create my first pixel art creation ~ the subject of the game, my spaceship ;). I used a processing library called gifAnimation which enable the use of animated gif. This give me some inspiration to create more games based on some gif sprite. Searching around the net I came accross this mini rpg sprite based game which is really fun and simple and also came across the pixel joint, a lair of pixel junkie artist that makes a lot of video game inspired graphic!

Explosion and laser beam was also something I explored in this project. You can fire the laser with the mouse click but shooting doesn’t do anything. You can even hold the mouse to hold the laser beam ~ again it doesn’t do anything ;). Explosion are also tricky because you want the ship to disappear and the action to stop yet you don’t want the main draw loop to stop. The explosion I ended up doing is really basic and lack refinement, but serves it’s purpose for now.

Also to simplify the creation of the floor and the celling I used a Perlin noise generator that create a semi random value that create a natural behavior to the randomness.So no more talk for now and play the game – there is no lives or score or counter of any sorts which remove any competition ;) Click here to play the game!

Comment » | game, processing, programming

diy audio mixer prototyping with arduino and processing

April 3rd, 2010 — 3:43pm

So here is my first step into my plan to make my own mixer. The idea is in the next few months I want to built a complete USB mixer (I say months not to get anyone hopes to high ;) )t . This mixer will be used to play with mixxx, which by the way will paticipate in the next google summer of code, where young programmer are giving the opportunity to code for few weeks on a certain project. These events in the past has help mixx to become quite solid mixing engine with a lot of neat feature and I am quite happy that it will again have a boost of new codes. That makes mixxx my prefered software for mixing – even if it’s not as solid sometime as other pro dj software – it’s open source and really easy to configure with a diy mixer for example :).

I chose Mixxx because it’s open source, it work on puredyne really well (far better than on ubuntu and a lot less ressource intensive than on mac) and work really well with my netbook with a 7inches screen. It’s also feature full and the midi mapping is really simple and kool.

The hardware I choose is the USB64 from doepfer that offer 64 connections that talk directly in MIDI trouh it’s usb port. But I soon realize that Doepfer make dyi gear that are not aimed toward the beginner in electronic, so my first step will be to start prototyping the device with my arduino mega board a sensor shield and 6 knob, 5 fader, some buttons and led.

One of the problem with arduino and midi is that the device itself is registered by the computer as a serial device, which create the needs to have a driver or a software that translate the serial output to midi output. I will probably use Processing to receive these serial message and display them as visual entry, or I might move that project to puredata ~ we will see what make more sense, puredata seems to be built to receive serial inputs, but I am more familiar with processing for now.

Once the prototype will be created and I will have some sort of casing and figured out the interface, I will jump on the soldering an cabling of the USB64.

Stay tuned for the development of this project, meanwhile enjoy some gear porn with these pictures of the parts I will be using. To keep it simple I got some pre-assembled knobs and fader that will connect directly to a sensor board that connect to the arduino mega. It’s a solder free prototype so I can focus on the software implementation.

Comment » | arduino, music, processing, programming

arduino & laser

March 22nd, 2010 — 9:41pm

This is a real beginner post – if you never played with arduino and laser you might find it fun, but it’s at the ‘hello world’ stage of arduino programing.

So I got myself some laser! I had a nice kaleidoscope green laser but I wanted to temper with it and ended up breaking it… Green and blue laser apart from being quite a nice colore laser, are really expensive. So I decided to buy some red laser to start with.

The Laser have 3 main component. The diode, which emits the light, the lens that focus that light, and the driver or the electronic component that help regulate the electricity to the diod itself, that is quite fragile by the way. My first instinct was to purchase the diode themselves, but realizing that there was some extra work needed to make them work for me, I also bough some more complete laser with the drivers and lens. Long story short I got some diodes, and some complete kit.

My plan is to create a device with arduino to have some sort of laser show. The first step was to connect one laser to the arduino board and see what are the posibility. Using the kaleidoscopic part of my other device I was able to put it on top of the laser.

Now the hard part is to find what can be interesting using only one laser and no motions control. Blinking feel too much like christmas light, strobing could be interesting, but can become annoying after a while, pulsating could be interesting… So the base is the arduino control over analogue port. A loop and analogue write.

Of course the most interesting would be to link the arduino react on the music rhythm, but that is a bit further down the road. I’ll tryout the basic arduino loop to create something interesting. The first thing I try was to simply input digital high and low – that was simply to make the laser blink. Using the digitalWrite to simplify the process. Later I started to play more with the analogue setting. I tried all I could with the blinking but the red blinking light was really resembling christmas light.

void() loop {
digitalWrite(LASER, HIGH); // turn the laser up
delay(120);                             //wait for a moment
digitalWrite(LASER, LOW);// turn the laser down
delay(120);                            // wait for a moment
}

So that wasn’t it. I tried modifying the delay, the pause and the length of the high value. Strobing was also an interesting effect, since the laser is connected to a kaleidoscope, but again not the effect I am looking for.

Adding random to the code made it a little more interesting

void() loop {
digitalWrite(LASER, HIGH); // turn the laser up
delay(int(random(1,100)));                             //wait for a RANDOM moment
digitalWrite(LASER, LOW);// turn the laser down
delay(int(random(1,100)));                            // wait for a RANDOM moment
}

That created an interesting effect. It started to give some sort of rhythm… but there is some sort of beat that is not there. Moving into the analogue realm I only started playing with fade in and fade out, as you can see, I didn’t get very far:


void() loop {

for ( int i =0; i<1000; i++)
{
analogueWrite(LASER,i);
}
delay(20)
}

Nothing very fancy, but I tried to match this with a fade out - creating another for loop. Again the effect is interesting - not too exciting but getting somewhere. And... that is where I got! If you have any idea what can be fun ~ I am giving up for now until I find more to do with arduino programming. I have also ordered some servo or controllable engines to give more flexibility with the project. Also I will be looking into the music integration where there could be some sort of reaction to the music from arduino, but that seems far down the road.

Comment » | arduino, programming

fish pond

March 6th, 2010 — 3:47pm


EDIT: Just so people are aware I am using the excellent book Learning processing written by Daniel Shiffman, which I forgot to mention since this article is part of a series of article about my self taught Processing training. END OF EDIT ~ This is my second project for processing fish pond. It’s not a game or anything, more an interactive pond where you control a fish that grows every time it eats food.

It’s mainly to practice object oriented programming with arrays and arrays of objects. With some random rain drop, I also practice with the rotate and translate function. Understanding that when using translate, your 0,0 coordinate becomes that translate. In order to draw a X and rotate it from it’s centre, you need to use negative value.

int r = 0;
void draw(){
translate(100,100);
line(-10,-10,10,10);
line(-10,10,10,-10);
rotate(radians(r));
r = r++;
}

Would create a X shape that rotate from it’s centre. The radians is used in order not to have to ply around with PI which is the default for the rotate function. I also used the % modulo to try to add some visual to the rotating X. The modulo is what remain after dividing a number by another number. So 10 % 3 is 1, and 9 % 3 is 0. It’s an interesting function to be able to create pulsing images.

In my last project blood in order to calculate if the mouse was on top of the first drop of blood I used a simple if mouseX to check if the mouse was over the drop. This time I used the dist function that calculate the distance between object. That created a cleaner code to verify if the fish was near enough of the food.

There is no goal to the game, simply to eat the food and grow the fish ;) I guess my next project will combine a goal as well as an interactive part… stay tune!

Comment » | game, programming

thinkering with arduino ~ lcd monitor and some knob

February 20th, 2010 — 3:24pm

So I’ve been playing with an arduino lately – with the help of pure dyne to connect to it.

The arduino is a toy for hacker – for hardware hacker or electronic enthusiast. I got it on ebay with an lcd screen with it and since I am starting to built a midi mixer (with some doepfer diy kit) I wanted to test some knobs and pots actions.

I’m not at the point to send signals from the arduino to the computer just yet – I am sure it’s not hard but haven’t been there. So in order to test any knob action I decided to use the lcd. To make thing even easier I bough some premade potentiometer with a shield that connects the potentiometer to the arduino. I agree that is being really lazy because when you start using the arduino you find quite early that connecting a switch or a potentiometer is the ‘hello world’ of arduino, or in layman term ‘it just take 3 wires and a resistance’. Cutting the crap here is what I did:

  • arduino mega board
  • 9v battery connector
  • shield for knobs and sliders
  • LCD shield to show the result

Without any idea of what I was doing I made a sandwich with the 3 board, stacking the sensor shield in between the arduino and the lcd shield, then connecting a knob to the first connection. I loaded the default example that comes with the lcd screen. At first the button on the screen wouldn’t work anymore. I realized that it was connecting on the same ‘in’ as my potentiometer. So playing around with the potentiometer I saw it was changing something on the screen! Hurray!

Hacking the example a little, to create something that make sense I ended up prototyping a volume knob that would indicate the level on the lcd screen. That was fun!

It was fun to realized that the shield are stack-able. Of course at this point this system is not usable it was mostly to test the interactivity with some knob action. Since I got an Arduino I can’t realize how easy it is to create fun stuff. This is also my first step at creating a complete usd midi mixer system to work with Mixxx

Comment » | arduino, programming

BLOOD –
my first processing game (kind of)

February 2nd, 2010 — 12:45pm

processingSo continuing my quest to learn processing. It’s a beautiful language really simple and well structured. I think it’s a really great way to learn programming at large.

This is my first ‘game’, or an interactive program that has a goal, a score and where difficulty increase the higher the score get. Now bare with me, this is not object oriented, I don’t use any fancy codes and now that I am learning about object oriented and class and array this code doesn’t really make sense at this point.

But it’s a great learning. If you are learning processing it’s a nice example of what can be done quickly without much knowledge.

BLOOD – the goal of the game is to mouse over the first drop of blood. There is so many drops that it would be impossible so the first drop get brighter and brighter the more drops fall. It’s a really simple randomization of translucide ellipse, and every frame an if check if your mouse is over that random first drop. In order to make it easier, the mouse position check is larger (+/- 10px). Every time the mouse position align with the first drop the screen clear, the drop starts small again and the speed increase. If the size of the drop gets bigger than the screen then you ran out of blood = you are game over !

Click here to play the game!

Comment » | game, programming

arduino + puredyne + netbook = fun

January 29th, 2010 — 2:24pm

pure-arduino

So I received my first arduino board, right after I successfully installed puredyne on my eeepc.

Puredyne is a wonderful system optimized for multimedia creation and computer art. It’s filled with all the linux tools to play music, program, edit images, video, audio. Loaded with pure data, super collider, processing and arduino to name a few – there is also a load of soft synth, dj mixing tools, multimedia player and also the basic file system and web browsing. It’s built on top of Ubuntu karmic koala so it offers quite a solid architecture while offering a good user interface and easy customization. It’s built with xfce instead of gnome in order to minimize the resources usage of the system, keeping the computing power of your machine for multimedia task.

puredyne Systems like puredyne are mostly created for a certain type of user, a user that care more about the power of the tool than the presentation, artist and thinkerer. When an artist is painting – he doesn’t really care if the paint container is nicely label, he doesn’t care if the studio he works in is a mess an located in an industrial building – what is important is that the tool respond to his or her creative impulse. That is what puredyne is, an artist tool crafted to be as powerful as possible for the computer artist.

It’s interesting to note that in this time of computing, where we rely more an more on browser based system, cloud computing and ‘thin client’ (sorry kids if you don’t get the thin client story… cloud computing has been around a lot longer than last year), I am asking why would we waste computer power on the user interface and the graphical system itself, the only real need is the multimedia factor of your machine. Operating system like puredyne is a really logical move in the overall operating system evolution.

0000003_300Arduino is, in short, a prototyping electronic device that you can program from a simple interface. Since I started learning processing, I was interested in Arduino since you can program Arduino with processing. So the processing-arduino integration provide a complete interactive creative system for computer artist. Arduino bards are pretty inexpensive and easy to purchase and they’re also modular, you can plug them in different shield (proto board that add to the main board) to create what you want to create, from controller to musical instruments.

In this example I used a lcd-keypad module from ekitszone.com directly on a arduino mega board. Every add on to the arduino needs some library and if you get boards that are minimally maintained you shouldn’t have much to worry. In this case I simply had to download the library from ekitszone and add it to my arduino library (opt/arduino/hardware/) and there were even example to get me started on that.

Where is it all going ? I feel with the learning of processing, arduino and my recent acquisition of electronic music devices there is something being blended together for my creative expression to flourish in some way. Hopefully something fun will come out of all that – but it might only be to keep my brain alive ;)

happy hacking!

Comments Off | arduino, programming

Back to top