Saturday, April 10, 2010
The light
As I have already worked on the light for idat209 I haven't done a lot of work on the light element of the project!
Thursday, April 8, 2010
ARDUINO - The Sound Code
For the thunder part of my animation I will use sound. For this I will use Arduino and build a sound sensing brick (see below).

The brick consists of a high sensitivity microphone and onboard Low Voltage Audio Power Amplifier. These measure the amplitude of sound in the environment. This data can then be used to start the effects on the screen, so in my case the storm starting on the screen.
The code for this would be very simple, it would just be a matter of telling the Arduino sensor that when the audio level reaches a certain level (eg 10DB so that normal ambient sounds do not effect the game) the animation starts.
I used similar code in my work for idat209 (see my post on light sensors).
The cost for the device would be around £20 and it would come with the necessary code to do it. Sadly it would take over a week to come as it is from Japan.
I have written up a code for a device to display sound levels with Arduino but not to do anything with them, this would be the part I'd need with the device.
The code would be similar to this...
/* ****************************************************
Arduino Code
**************************************************** */
int analogValue;
int val;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// read analog input
analogValue = analogRead(0);
// send values to processing
Serial.println(analogValue, DEC);
// pause for 10 milliseconds:
delay(10);
}
/* ****************************************************
Processing Code
**************************************************** */
// import the Processing serial library
import processing.serial.*;
// declare a font variable
PFont font48;
int linefeed = 10;
// Linefeed in ASCII
Serial myPort;
// The serial port
// value recieved from the serialport / arduino
int sensorValue;
// mapped value
float sensorValueMap;
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Setup
void setup() {
myPort = new Serial(this, Serial.list()[0], 9600);
// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(linefeed);
size (800, 600);
background (0);
//smooth();
//load font;
font48 = loadFont(“alask_48.vlw”);
textFont(font48);
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Serial Event
void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil(linefeed);
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
//println(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));
// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
//print(“Sensor ” + sensorNum + “: ” + sensors[sensorNum] + “\n”);
// sensor
sensorValue = sensors[0];
//sensorValueSmooth = sensors[1];
}
}
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Draw a DB level viewer
void draw() {
// set the black background
background(0);
// run the displayText() function
displayText();
// map the received values
sensorValueMap = map(sensorValue, 0, 1024, 0, 800);
// draw a rectangle based on the variable sensorValueMap
rect (0, 100, width, sensorValueMap);
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Display Text
void displayText() {
text(“Sensor Value”, 20, 80);
text(sensorValue, 450, 80);
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Save image
void keyPressed(){
if(key==’s’)
saveFrame(“sound-######.png”);
}
//------------ end of code
The brick consists of a high sensitivity microphone and onboard Low Voltage Audio Power Amplifier. These measure the amplitude of sound in the environment. This data can then be used to start the effects on the screen, so in my case the storm starting on the screen.
The code for this would be very simple, it would just be a matter of telling the Arduino sensor that when the audio level reaches a certain level (eg 10DB so that normal ambient sounds do not effect the game) the animation starts.
I used similar code in my work for idat209 (see my post on light sensors).
The cost for the device would be around £20 and it would come with the necessary code to do it. Sadly it would take over a week to come as it is from Japan.
I have written up a code for a device to display sound levels with Arduino but not to do anything with them, this would be the part I'd need with the device.
The code would be similar to this...
/* ****************************************************
Arduino Code
**************************************************** */
int analogValue;
int val;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// read analog input
analogValue = analogRead(0);
// send values to processing
Serial.println(analogValue, DEC);
// pause for 10 milliseconds:
delay(10);
}
/* ****************************************************
Processing Code
**************************************************** */
// import the Processing serial library
import processing.serial.*;
// declare a font variable
PFont font48;
int linefeed = 10;
// Linefeed in ASCII
Serial myPort;
// The serial port
// value recieved from the serialport / arduino
int sensorValue;
// mapped value
float sensorValueMap;
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Setup
void setup() {
myPort = new Serial(this, Serial.list()[0], 9600);
// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(linefeed);
size (800, 600);
background (0);
//smooth();
//load font;
font48 = loadFont(“alask_48.vlw”);
textFont(font48);
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Serial Event
void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil(linefeed);
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
//println(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));
// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
//print(“Sensor ” + sensorNum + “: ” + sensors[sensorNum] + “\n”);
// sensor
sensorValue = sensors[0];
//sensorValueSmooth = sensors[1];
}
}
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Draw a DB level viewer
void draw() {
// set the black background
background(0);
// run the displayText() function
displayText();
// map the received values
sensorValueMap = map(sensorValue, 0, 1024, 0, 800);
// draw a rectangle based on the variable sensorValueMap
rect (0, 100, width, sensorValueMap);
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Display Text
void displayText() {
text(“Sensor Value”, 20, 80);
text(sensorValue, 450, 80);
}
// – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – - – Save image
void keyPressed(){
if(key==’s’)
saveFrame(“sound-######.png”);
}
//------------ end of code
Thursday, April 1, 2010
Non Arduino Insperations
Just a few interactive things which actually led me to my idea of the weather game, not based on arduino but all fab ideas that I was thinking of using before I went with Ardunio
This interactive video based on the game Team Fortress 2, the user must guide the "heavy" through the level to gain the intel.
Similar to the TF2 game but with real people and time travel!
Subservient Chicken
The Subservient Chicken is an advertising program created to promote international fast food restaurant chain Burger King's TenderCrisp chicken sandwich and their "Have it Your Way" campaign. Created for the Miami-based advertising firm Crispin Porter + Bogusky (abbreviated to CP+B) by The Barbarian Group, the program featured a viral marketing website, television and print campaigns and a one time pay-per-view program. The program was similar to other marketing campaigns created by CP+B for Burger King, including the Coq Roq, Ugoff, and Sith Sense.
These are weather games from the BBC website, they aren't really like my weather game but I took a few ideas from here and I doubt there will be many games like my idea anyway.
Stormtroopers
WeatherMap Game
This interactive video based on the game Team Fortress 2, the user must guide the "heavy" through the level to gain the intel.
Similar to the TF2 game but with real people and time travel!
Subservient Chicken
The Subservient Chicken is an advertising program created to promote international fast food restaurant chain Burger King's TenderCrisp chicken sandwich and their "Have it Your Way" campaign. Created for the Miami-based advertising firm Crispin Porter + Bogusky (abbreviated to CP+B) by The Barbarian Group, the program featured a viral marketing website, television and print campaigns and a one time pay-per-view program. The program was similar to other marketing campaigns created by CP+B for Burger King, including the Coq Roq, Ugoff, and Sith Sense.
These are weather games from the BBC website, they aren't really like my weather game but I took a few ideas from here and I doubt there will be many games like my idea anyway.
Stormtroopers
WeatherMap Game
Subscribe to:
Comments (Atom)