Signal strength on Freetronics board

Hey there,

I have been using a Freetronics 100% Arduino Compatible board to run switches that trigger sound file players in MaxMSP.

The only sketch and patch I could use to get the board and Max communicating was Arduino2Max. I am able to get 1's and 0's out of the board using the Arduino2Max patch to trigger the sound file players on and off but the signal is extremely ambiguous. When the switch is open it should be sending a 0, when it is closed a 1 but it is flickering between the two. It also can take up to 4 secs to switch back to a 0 to close the switch. When the sample rate is slowed it just means that the signal flickers at a slower rate.

I have tried using a prototyping board as well as plugging directly into the digital pins. Can someone please give me any advice? Could this be a signal issue to do with the quality of the wires I am using or could there be a problem with the board or the way the signal is converted through usb?

Thanks!!

Here is a copy of the code for the patcher in MaxMSP. If someone with experience with Max and Arduino could give me a hand that would be greatly appreciated.

{
"patcher" : {
"fileversion" : 1,
"rect" : [ 0.0, 44.0, 1280.0, 726.0 ],
"bglocked" : 0,
"defrect" : [ 0.0, 44.0, 1280.0, 726.0 ],
"openrect" : [ 0.0, 0.0, 0.0, 0.0 ],
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 0,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 0,
"toolbarvisible" : 1,
"boxanimatetime" : 200,
"imprint" : 0,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"boxes" : [ {
"box" : {
"maxclass" : "number",
"outlettype" : [ "int", "bang" ],
"fontsize" : 12.0,
"numinlets" : 1,
"id" : "obj-2",
"patching_rect" : [ 221.0, 540.0, 50.0, 20.0 ],
"fontname" : "Arial",
"numoutlets" : 2
}

}
, {
"box" : {
"maxclass" : "ezdac~",
"presentation_rect" : [ 764.0, 176.0, 45.0, 45.0 ],
"numinlets" : 2,
"id" : "obj-52",
"patching_rect" : [ 875.0, 322.0, 45.0, 45.0 ],
"presentation" : 1,
"numoutlets" : 0
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "0",
"outlettype" : [ "" ],
"fontsize" : 12.0,
"numinlets" : 2,
"id" : "obj-18",
"patching_rect" : [ 304.0, 644.0, 32.5, 18.0 ],
"fontname" : "Arial",
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "1",
"outlettype" : [ "" ],
"fontsize" : 12.0,
"numinlets" : 2,
"id" : "obj-44",
"patching_rect" : [ 232.0, 643.0, 32.5, 18.0 ],
"fontname" : "Arial",
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "toggle",
"outlettype" : [ "int" ],
"numinlets" : 1,
"id" : "obj-45",
"patching_rect" : [ 108.0, 636.0, 20.0, 20.0 ],
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "toggle",
"outlettype" : [ "int" ],
"numinlets" : 1,
"id" : "obj-46",
"patching_rect" : [ 134.0, 637.0, 20.0, 20.0 ],
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "sel 0 1",
"outlettype" : [ "bang", "bang", "" ],
"fontsize" : 12.0,
"numinlets" : 1,
"id" : "obj-47",
"patching_rect" : [ 222.0, 578.0, 46.0, 20.0 ],
"fontname" : "Arial",
"numoutlets" : 3
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "p Sound File Player 1",
"linecount" : 2,
"presentation_linecount" : 2,
"color" : [ 1.0, 0.0, 0.419608, 1.0 ],
"fontsize" : 12.0,
"presentation_rect" : [ 231.0, 426.0, 93.0, 34.0 ],
"numinlets" : 1,
"id" : "obj-48",
"patching_rect" : [ 397.0, 571.0, 93.0, 34.0 ],
"fontname" : "Arial",
"presentation" : 1,
"numoutlets" : 0,
"patcher" : {
"fileversion" : 1,
"rect" : [ 51.0, 94.0, 299.0, 412.0 ],
"bglocked" : 0,
"defrect" : [ 51.0, 94.0, 299.0, 412.0 ],
"openrect" : [ 0.0, 0.0, 0.0, 0.0 ],
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 0,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 0,
"toolbarvisible" : 1,
"boxanimatetime" : 200,
"imprint" : 0,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"boxes" : [ {
"box" : {
"maxclass" : "message",
"text" : "loop $1",
"outlettype" : [ "" ],
"fontsize" : 12.0,
"numinlets" : 2,
"id" : "obj-8",
"patching_rect" : [ 196.0, 55.0, 50.0, 18.0 ],
"fontname" : "Arial",
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "inlet",
"outlettype" : [ "" ],
"numinlets" : 0,
"id" : "obj-7",
"patching_rect" : [ 45.0, 16.0, 25.0, 25.0 ],
"numoutlets" : 1,
"comment" : ""
}

}
, {
"box" : {
"maxclass" : "gain~",
"outlettype" : [ "signal", "int" ],
"numinlets" : 2,
"id" : "obj-5",
"patching_rect" : [ 122.0, 116.0, 67.0, 104.0 ],
"numoutlets" : 2
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "open",
"outlettype" : [ "" ],
"fontsize" : 12.0,
"numinlets" : 2,
"id" : "obj-4",
"patching_rect" : [ 123.0, 35.0, 37.0, 18.0 ],
"fontname" : "Arial",
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "toggle",
"outlettype" : [ "int" ],
"numinlets" : 1,
"id" : "obj-3",
"patching_rect" : [ 86.0, 37.0, 20.0, 20.0 ],
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "sfplay~",
"outlettype" : [ "signal", "bang" ],
"fontsize" : 12.0,
"numinlets" : 2,
"id" : "obj-2",
"patching_rect" : [ 123.0, 76.0, 49.0, 20.0 ],
"fontname" : "Arial",
"numoutlets" : 2,
"save" : [ "#N", "sfplay~", "", 1, 120960, 0, "", ";" ]
}

}
, {
"box" : {

And here is a photo of the circuit.

And this is the sketch I'm using...

/*

  • Arduino2Max
  • Send pin values from Arduino to MAX/MSP
  • Arduino2Max.pde

  • This version: .4, October 2007

  • Copyleft: use as you like
  • by Daniel Jolliffe
  • Based on a sketch and patch by Thomas Ouellet Fredericks tof.danslchamp.org

*/

int x = 0; // a place to hold pin values
int ledpin = 13;

void setup()
{
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
digitalWrite(13,HIGH); ///startup blink
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}

void loop()
{

if (Serial.available() > 0){ // Check serial buffer for characters

if (Serial.read() == 'r') { // If an 'r' is received then read the pins

for (int pin= 0; pin<=5; pin++){ // Read and send analog pins 0-5
x = analogRead(pin);
sendValue (x);
}

for (int pin= 2; pin<=13; pin++){ // Read and send digital pins 2-13
x = digitalRead(pin);
sendValue (x);
}

Serial.println(); // Send a carriage returnt to mark end of pin data.
delay (5); // add a delay to prevent crashing/overloading of the serial port

}

}
}

void sendValue (int x){ // function to send the pin value followed by a "space".
Serial.print(x);
Serial.print(32, BYTE);
}

Next time you post code use the # button >:(

You have no pull up resistor on that switch and you haven't enabled the internal pull ups either.

Wow you really are grumpy huh? Thanks for your help :wink: