Corrected the issue using this link
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Electronics;action=display;num=1212032726
Load the ArduinoBT with the firmata firmware .pde file. I used simple_analog.pde for this test. Works Great.
Pins 0, 1, 2 have TEMT6000 ambient light sensors attached to them.
Code:
/*
###################################################################################
Audio visual interface - for nuit blance
sketch and hardware (c)2008 August 20 Brian Durocher
___________________________________________________________________________________
uses Arduino Library from
http://www.arduino.cc/playground/uploads/Interfacing/processing-arduino2.zip
Serial
Sound libray - Sonia
Requires JSyn Library Win / Mac / Linux
###################################################################################
for interactive project with Emmanuelle Raynault (Paris), Duncan MacDonald (Canada),
and myself Brian Durocher (Canada)
for questions or concerns please contact Brian Durocher at brian.durocher@gmail.com
ArduinoBT Must Be Reset just before program execution for this to work.
Board is loaded with Firmata firmware
###################################################################################
*/
import pitaru.sonia_v2_9.*;
import processing.serial.*;
import cc.arduino.*;
Sample mySample;
int analogPin0 = 0;
int analogPin1 = 1;
int analogPin2 = 2;
int analogValue0 = 0;
int analogValue1 = 0;
int analogValue2 = 0;
Arduino arduino;
void setup()
{
println(Arduino.list());
size(512, 200);
Sonia.start(this); // Start Sonia engine.
// create a new sample object.
mySample = new Sample("sine.aiff");
arduino = new Arduino(this, Arduino.list()[10], 57600); //open up arduino for use with processing
}
void draw(){
analogValue0 = arduino.analogRead(analogPin0);
int inByte0 = int(map(analogValue0,0,1023,0,255)); // mapping the analogSensor values (0-1023) to values between 0-255
println(analogValue0);
analogValue1 = arduino.analogRead(analogPin1);
int inByte1 = int(map(analogValue1,0,1023,0,255)); // mapping the analogSensor values (0-1023) to values between 0-255
println(analogValue1);
analogValue2 = arduino.analogRead(analogPin2);
int inByte2 = int(map(analogValue2,0,1023,0,255)); // mapping the analogSensor values (0-1023) to values between 0-255
println(analogValue2);
//play audio if values are withing range
background(0);
//background(0);
stroke(0);
rectMode(CENTER);
fill(inByte0, 0, 0);
rect(100, 20, 5, 5);
rectMode(CENTER);
fill(inByte1, 0, 0);
rect(120, 20, 5, 5);
rectMode(CENTER);
fill(inByte2, 0, 0);
rect(140, 20, 5, 5);
}//end of draw
void keyPressed() {
if (key == 'a'){
mySample.repeat();
}
else if(key == 's'){
mySample.stop();
}
}
void setRate(){
// set the speed (sampling rate) of the sample.
// Values:
// 0 -> very low pitch (slow playback).
// 88200 -> very high pitch (fast playback).
//float rate = (height - mouseY)*88200/(height);
float rate = 44000;
mySample.setRate(rate);
}
void stop()
{
// always close Sonia audio classes when you are done with them
// dealocates memory space
Sonia.stop();
super.stop();
}
Firmata Firmware
Code:
/* Copyright (C) 2008 Free Software Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* See file LICENSE.txt for further informations on licensing terms.
*/
/* Supports as many analog inputs and analog PWM outputs as possible.
*
* Written by Hans-Christoph Steiner <hans@eds.org>
*/
#include <Firmata.h>
byte analogPin;
void analogWriteCallback(byte pin, int value)
{
pinMode(pin,OUTPUT);
analogWrite(pin, value);
}
void setup()
{
Firmata.setFirmwareVersion(0, 1);
Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
Firmata.begin();
}
void loop()
{
while(Firmata.available()) {
Firmata.processInput();
}
for(analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
Firmata.sendAnalog(analogPin, analogRead(analogPin));
}
}
Works. Now to get the standard firmata firmware a test.