Yay...
Hi, I am just starting with arduino, and still not very experienced in PD.
I have found tons of great info around here, thanks for that.
For me, everything works up to a point:
* I successfully upload the Firmata
* the output example in Processing works, I am able to turn pin 13 on and off
* in PD I open the correct port ("[comport] opened serial line device 3 (/dev/ttyUSB0)")
however, I have not been able to get any communication with the arduino in PD using Hans-Christoph Steiner's [arduino] - either turn pin 13 on/off or get firmware information. The numerical commands sent to [comport] seem correct, e.g. 249 for version information, etc.
So, the only place it seems possible to be going wrong is either [comport] or after that, along the line. As I said, it works with the same port from Processing, and at the same rate - 115200
"get_baud_ratebits: 115200.000000
set_baudrate baudbits: 4098 /***(what does this second line mean?)
[comport] opened serial line device 3 (/dev/ttyUSB0)"
I am running Ubuntu Intrepid, latest versions of Pd-extended, Arduino IDE, Firmata. The board is old though, "Arduino NG or older w/ ATmega8" but I guess this doesn't matter if the above mentioned things work.
I still have to test it for input, but I have to pick up some sensors from the shop.
If [arduino] does not work out I may try Messenger, but it really seemed quite good for what I am trying to do (drums with input from piezo elements).
edit:
This *may* have been due to a bad Arduino board, because I am now unable to transfer any sketches to it. Surprisingly though the Processing example still works (Firmata is left on the board from the time transfers worked)
Yay...
I took this from my blog which is an eyesore and hard to concentrate on.
Let's learn how to combine arduino and puredata into one almighty power, the mighty AARRGHDATA(i think the proper name is the classier pduino, i guess you say it peedweeno, or padooiino)
Firstly. If you haven't already, check that your arduino is working. if you know this. keep scrolling until you see a kitten.
Plug it in and fire up the arduino software. You can get that from here
now lets do a quick test(is shouldve flashed when you plugged it in anyway) but get an LED, and put it so that the longer leg(theres a fancy name for this) is in the slot for digital pin 13 and the shorter leg(also has a fancy name) is in GND(you could say things "gund" or "gnnnd" but im fairly sure it just means GROUND.
now go file>sketchbook>examples>digital>blink and it will open that sketch. click the "upload" button and watch as it updates you on upload status and tells you when its complete.
is it blinking? nice. i could go on more about this, but i want to talk about PD, thats where it gets fun.
KITTENS
you can start looking again if you like pd.
once again, go to file>sketchbook>examples>library-firmata>standard firmata
dont see it? its a standard library now, so you should probably check you have the latest version(anything above 12 will be fine)
around this time you want to open pd and try create an object called "arduino". nothing? then you need to be going here to visit the wonderful mr hans, and download pduino.(i'm not sure if the arduino library is standard in pd extended now)
did you upload that standard firmata sketch to your board? i didnt tell you to. but thats ok, i like the way you think. do that if you haven't.
once thats uploaded properly, you can quit the arduino software, we do not need its services anymore.
now go inside that pduino folder you downloaded and open the patch arduino-test.pd
you should see something like thisss.
i dont know why all those errors happen. but click the "devices" message box in there to check what port your arduino is on.
hans is pretty awesome for making this patch, its really easy to understand i think.
change your port to whatever pd tells you your arduino is on.
HUZZAH! CONNECTIVITY!
now, lets say we still have that LED plugged in. want to test it?
hit that "pulse all outputs" toggle, and it should blink on and off. look around that subpatch, its pretty simple too. (you will want to know all these messages to send when writing your own patch for stuff)
Input is easy too. turn on that little toggle under [arduino 1] to let through outlet info.
you'll also want to enable your analogIns in the yellow radio up there.
say you had a potentiometer you wanted to connect up, it's really easy. and a breadboard will make all your connections easier to make.
but you'd just connect it up like this.
then you'd just enable the input you are using in that patch(input 2 in this case) and watch the input stream in through the a3 number box at the bottom.
this is how it works for me anyway.
that should just show you how the basics of it work, and you can move from there.
Control analog sensor data in PD?
damn godinpants, that was exactly what i needed!! damn i'm excited now, its starting to work out! i also divided the soundfiler info by 100 and multiplied it to the signal before the [pack 0 100]. that made sure it worked for the full sound file instead of just 0-44100.
i have two sensors. one sensor is the scratcher: the soundfile is played fast/slow depending on how fast i move an object closer to the sensor. I dont know if that makes sense. is it possible to have the other sensor slow down the speed of the playback??
for instance, i have a 10 second file. i made the vertical slider range from 20-100 because that's the range the signal is clearest. if i move my hand slowly closer to the sensor, the 10 second sound file plays forward. i want the other sensor to "zoom" into the vertical slider and make, for instance, the 20-30 range the range that the 1st-scratcher-sensor is working with. if my left hand is using the 2nd "zoom" sensor, and my right hand is using the 1st "scratcher" sensor, my left hand will pinpoint a section of the sound file that i want my right hand, the scratcher, to play back and forth.
Whats the best way to do that? (sorry for the long detailed messages, i just try to make sure you guys understand my situation)
Control analog sensor data in PD?
Hi! There is so much documentation online, but i still cant seem to figure this out:
I have a sharp gp2d120 sensor hooked up to my arduino. The arduino has firmata 2.0 installed so that it can communicate to PD (using pduino). I am getting a steady stream of voltage data from the sensor (as you can see from the the 4th analog pin in the screenshot). I'm trying to figure out how i can turn this data into something i can work with. Or maybe i need to learn how to work with it. Ultimately i want to control the frequency of a sound file based on the voltage output of the sensor (which is relative to the proximity of an object to the sensor).
So how can i convert this analog data into something i can work with (some data type that i can [delay] and that i can output to [dac~]? Do i need to use [mtof] to convert it to frequency? Do i need to turn it into a MIDI device somehow? [ctlin]? [tabread4]? These are just some objects that have come up after i searched for solutions, but i don't know how to execute it all.
side note: is it possible to set the sample rate of arduino in PD? the sensor works best with 10ms intervals between each sample.
Arduino and pure data
Hello. I'm trying to use Arduino with Puredata using the Firmata Library. I downloaded Firmata and installed the library as instructed in the readme, and then loaded 'AnalogFirmata' from the library examples. When I try to compile this example (or any of the others) I receive a string of error statements. Code and errors listed below. Any suggestions?
Code:
/* This firmware supports as many analog ports as possible, all analog inputs,
* four PWM outputs, and two with servo support.
*
* This example code is in the public domain.
*/
#include <Firmata.h>
#include <Servo.h>
/*==============================================================================
* GLOBAL VARIABLES
*============================================================================*/
/* servos */
Servo servo9, servo10; // one instance per pin
/* analog inputs */
int analogInputsToReport = 0; // bitwise array to store pin reporting
int analogPin = 0; // counter for reading analog pins
/* timer variables */
extern volatile unsigned long timer0_overflow_count; // timer0 from wiring.c
unsigned long nextExecuteTime; // for comparison with timer0_overflow_count
/*==============================================================================
* FUNCTIONS
*============================================================================*/
void analogWriteCallback(byte pin, int value)
{
switch(pin) {
case 9: servo9.write(value); break;
case 10: servo10.write(value); break;
case 3:
case 5:
case 6:
case 11: // PWM pins
analogWrite(pin, value);
break;
}
}
// -----------------------------------------------------------------------------
// sets bits in a bit array (int) to toggle the reporting of the analogIns
void reportAnalogCallback(byte pin, int value)
{
if(value == 0) {
analogInputsToReport = analogInputsToReport &~ (1 << pin);
}
else { // everything but 0 enables reporting of that pin
analogInputsToReport = analogInputsToReport | (1 << pin);
}
// TODO: save status to EEPROM here, if changed
}
/*==============================================================================
* SETUP()
*============================================================================*/
void setup()
{
Firmata.setFirmwareVersion(0, 2);
Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
servo9.attach(9);
servo10.attach(10);
Firmata.begin();
}
/*==============================================================================
* LOOP()
*============================================================================*/
void loop()
{
while(Firmata.available())
Firmata.processInput();
if(timer0_overflow_count > nextExecuteTime) {
nextExecuteTime = timer0_overflow_count + 19; // run this every 20ms
for(analogPin=0;analogPin<TOTAL_ANALOG_PINS;analogPin++) {
if( analogInputsToReport & (1 << analogPin) )
Firmata.sendAnalog(analogPin, analogRead(analogPin));
}
}
}
Error Statements:
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:61: error: typedef 'callbackFunction' is initialized (use __typeof__ instead)
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:61: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:61: error: expected primary-expression before 'int'
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: typedef 'sysexCallbackFunction' is initialized (use __typeof__ instead)
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'argv' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:81: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:81: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:86: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:87: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:88: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:90: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:91: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:91: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:91: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:95: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:95: error: 'callbackFunction' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:96: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:97: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:98: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:98: error: 'sysexCallbackFunction' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:98: error: 'void FirmataClass::attach(int, int)' cannot be overloaded
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:95: error: with 'void FirmataClass::attach(int, int)'
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:99: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:104: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:105: error: ISO C++ forbids declaration of 'byte' with no type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:105: error: expected ';' before '*' token
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:107: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:108: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:109: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:110: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:112: error: 'boolean' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:115: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:116: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:117: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:118: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:119: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:122: error: 'sysexCallbackFunction' does not name a type
In function 'void setup()':
Interfacing PD with the Arduino ... how?
i got a problem in uploading the file to the board. ( I have press play, same error found. When I press upload to I/O, below error found)
anyone can help?
thx
////////////////////////////
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:61: error: typedef 'callbackFunction' is initialized (use __typeof__ instead)
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:61: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:61: error: expected primary-expression before 'int'
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: typedef 'sysexCallbackFunction' is initialized (use __typeof__ instead)
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'byte' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:64: error: 'argv' was not declared in this scope
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:81: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:81: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:86: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:87: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:88: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:90: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:91: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:91: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:91: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:95: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:95: error: 'callbackFunction' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:96: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:97: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:98: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:98: error: 'sysexCallbackFunction' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:98: error: 'void FirmataClass::attach(int, int)' cannot be overloaded
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:95: error: with 'void FirmataClass::attach(int, int)'
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:99: error: 'byte' has not been declared
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:104: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:105: error: ISO C++ forbids declaration of 'byte' with no type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:105: error: expected ';' before '*' token
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:107: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:108: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:109: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:110: error: 'byte' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:112: error: 'boolean' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:115: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:116: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:117: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:118: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:119: error: 'callbackFunction' does not name a type
/Applications/arduino-0012/hardware/libraries/Firmata/Firmata.h:122: error: 'sysexCallbackFunction' does not name a type
In function 'void setup()':
Interfacing PD with the Arduino ... how?
I've got an Arduino Diecimila which works perfectly with PD. It really is super simple to set up!
1. Download Pduino AND Firmata:
http://at.or.at/hans/pd/objects.html
2. Download Arduino Software for your operating system:
http://arduino.cc/en/Main/Software
3. Attach your Arduino board via USB cable, launch Arduino Software and open "Standard_Firmata" from Firmata/examples. Upload this to your board.
4. Launch PD and open "arduino-test.pd"
5. Select the right COM port (click on each one until PD message window reports something positive). Then enable the PIN you've got your sensor attached to. Value in a relevant box will start updating. If you haven't got a sensor but just want to make sure it's working, click "Pulse all outputs". An LED on the board will start flashing repeatedly.
That's all you need to get going.
Let us know how it goes.
Good luck!
PD with arduino and IR sensors
@lunchbox said:
is there any differences between the firmata and the simple messaging system? I'm also working with IR sensors, arduino connected to PD, and i need to read inputs from the arduino, so which external is better? I've tried the firmata, it works well, but i still don't get how this external works...
Yep, there is a difference. The difference is that firmata is designed to let everything happen in software, rather then on the arduino (see my attached example on the other post for an example of how to read your IR sensors)
Better is subjective. I like Pd coding better, so I use pduino and firmata.
So, to recap, burn firmata standard on your arduino, use Pduino, and code the app in pd, for easy, graphical, dynamic programming (pd-style) otherwise, interpret the messages in some other format, and do it some other way. It's up to you.
My attached example is definitely the easiest way to achieve your goals, in my opinion. You get the bonus of having pretty simple conversion from Arduino-languuage examples into pd-friendly code, rather then using some intermediary language that you have to code for on both ends (arduino interprets inputs, emits OSC or something else on serial, pd interprets OSC or something else and does stuff, blech!) instead you can just route incoming messages in pd, the same way you would with midi, a joystick, keys, or whatever.
Once you get pduino all setup, and my above patch works, try right-clicking on Pduino object, and choosing help. It actually has a pretty nice help file, which is how I figured all this out.
PD with arduino and IR sensors
Did you burn the Pduino (Firmata) firmware on there? It's needed to make the arduino pd patch work. After that, you can just send commands to it, instead of writing your code to the arduino. It's a serial interface for PD. It already has the baud set correctly.
To install it, copy the "Firmata" dir (inside Firmata-2.0beta in Pduino distro) to arduino/hardware/libraries. After that, open the arduino IDE, and go to Sketchbook/Examples/Library_Firmata/Standard_Firmata. Burn this to your Arduino.
See the attached patch for an example of what you are trying to do, once you get Firmata installed. On the hardware end, connect photodetector to power and pin2.
Pd+icube
yeah it would definately work with pd.
and i think there are a few pd users who might have an icube system.
the main problem is that the icube stuff is really overpriced.
i think most of the sensor - pd users are on the mailing list, so you can direct your questions there, but don't be surprised when they tell you to steer clear of the icube stuff. really it is a ripoff. the sensors they sell you, you can buy very cheaply at electronics shops. all you have to do is learn how to solder some wires to them and stuff.
i hear lots about arduino, so maybe that's a good way to go. http://www.arduino.cc/