Lilypad light sensor maxuino

Hi
This is my 1st post in this forum and surely not the last, being really new in arduino microcontroller domain.
Although I don't think it'll take to long. Everything seems to be pretty straight forward.

My question is ;

I am using Maxuino in (Max msp) as an interface to read the incoming data from the lilypad light sensor, and it behaves erractically.

I know it has nothing to do w. the light sensor , because it works fine when using the Arduino's serial monitor. Outputing a range from ( 1 - 1200) .

What to do to get this same sort of smooth behavior in Max msp?

Do I have to use Maxuino to use Max msp as an interface or could I built my own?

If I can built my own Max arduino objects, I do I go about doing that/ how does max and arduino comunicate ?

When I read that Arduino is easy to use w. Maxmsp, did they mean that you have to use the already existing patches available in the arduino Playground?? <- Which is fine w. me , as long as they work ; )

Last, where would I get the lilypad code for the XL 330 accelerometer???

Thanks a millions in advance for any help on this.
Sorry for so many question, I'm just so anxious to learn this great stuff.

phil

Are you writing you own code or using the samples on the Arduino Playground.

Please share your code so we can troubleshoot it, it could be something a simple as rollover(1023 is ok, but as soon as it hits 1024 for example, it could drop back to 0 or 1)

In what way is it erratic, like jumping around within a couple values(1000, then 1023 then 987, etc) or is it major, like 1, 886, 27, 56, 838

I hade the same kind of pb hooking up an Arduino with max/msp. My problem was because the arduino was sending something like
Serial.print(12), and I was receiving odd values on the other side.
In fact, the arduino was sending this as ASCII values, so 1 = 49, 2 = 50 > 12 = 49 50.
After reading the help, I came with this patch

You just have to modify a little your arduino code by adding a Serial.println() after each value.
The orange box is used to reconvert ASCII to integers.

With this kind of patch, you don't need to use maxuimo, firmata or whatever, just make your code, and you don't need to use the max patches made for those firmware, just your regular max/msp patch.

Sorry for slow reply , long day of work away from any computers
But Thanks a million for your generosity (patch and time!)

In fact, the arduino was sending this as ASCII values, so 1 = 49, 2 = 50 > 12 = 49 50.
Why does it send as ASCII? Is that how arduino works?>(really I haven't read this anywhere!)

With this kind of patch, you don't need to use maxuimo, firmata or whatever, just make your code, and you don't need to use the max patches made for those firmware,
So, we don't need firmata ? or anything else. What translates the data to max msp? What do you mean by make your own code. <- how do we do that.
What do you mean >you don't need to use the max patches made for those firmware.> What is firmware (the atmega 168 chip / I thought firmware meant --read only ?? the arduino goes both send [read and send] NO?? (<- sorry for my ignorance ; ).

We still need to built a code in C and load it on the chip w. the arduino software don't we?

Again sorry for the slow reply , and thanks a million for your patch generosity.

If you have any questions at all about maxmsp <- algorithmic music or just using for musical ideas and need pointers , it will be more than my pleasure if I could be of any help at all .

Thanks again, forums are what completely built my education w. max msp

phil

Another quick question.

I see you [metro] had an 0.001 argument. <- you can have those ?? I thought the lowest was 1. (no floats) ?? I this a new thing in max 5?

thanks

phil

Sorry, I don't know if it's new, just tested it and worked ^^
I'm pretty new with max/msp

hi

I'm new to arduino/programming & pd too but needed to use pd without firmata, to get the correct values into pd/max you need to format the print statement. eg:

Serial.print(val, BYTE)

There is more info about serial.print in the reference area of the arduino website.

That reference area is also included with the arduino software, so you can browse it offline.

By not using firmata you lose the ability to differentiate messages because you just receive a continuous stream of numbers, so you need to create your own method of identifying which is which.
The max patch above looks like it does that but you might be better to create you own way, say send two bytes and use the first byte for id, then in max use route(pd) or sel to route where needed.

Lee

The max patch above was made for a particular use. I send a message to the arduino, the arduino reads the sensor from an optical mouse and sends me 324 values, with a println between each value.
The patch takes this data, converts the ASCII (it's in ascii because I use simple Serial.print(value):wink: into integers by using the println ascii equivalent (13) to separate each data. It then puts all this data in a list of 324 elements, etc.... but that's just max giberrish after that ^^

Hi and thanks lee
As I figure this out hopefully I can come as some aid @ some point

you said ;

you need to format the print statement. eg:
-you do mean in the arduino software code right-> so it can be uploaded on the board then feed it to the max [serial] object?

There is more info about serial.print in the reference area of the arduino website.
http://www.arduino.cc/en/Reference/HomePage

I have read it and it simply explain the syntax not how it works. Or am I missing somthing.

That reference area is also included with the arduino software, so you can browse it offline.

I have search the Arduino app./ my computer Hd and have found nothing of this. If I knew there was a reference area I would try avoiding bugging you guys. Or at least for a while ; )

The max patch above looks like it does that but you might be better to create you own way, say send two bytes and use the first byte for id, then in max use route(pd) or sel to route where needed.

Sorry again for my ignorance but, if I understand correctly , 1 byte is equivalent to one value in this case??

In this following code, does it mean 1 byte or 1 value is send every 100 ms. What does baud 9600?? what does 9600 stand for??

here is the code;

/*

  • LilyPad tutorial: sensing (sensors)
  • Reads data from a LilyPad light sensor module
  • and then sends that data to the computer
  • so that you can see the sensor values
    */

int ledPin = 13; // LED is connected to digital pin 13
int sensorPin = 0; // light sensor is connected to analog pin 0
int sensorValue; // variable to store the value coming from the sensor

void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
Serial.begin(9600); //initialize the serial port
digitalWrite(ledPin, HIGH); // turn the LED on
}

void loop() // run over and over again
{
sensorValue = analogRead(sensorPin); // read the value from the sensor
Serial.println(sensorValue); // send that value to the computer
delay(100); // delay for 1/10 of a second
}

Thanks a lot for your efforts

phil

you said ;

you need to format the print statement. eg:
-you do mean in the arduino software code right-> so it can be uploaded on the board then feed it to the max [serial] object?

Yes, the arduino code, by format i mean print it in a format that you require.

There is more info about serial.print in the reference area of the arduino website.
http://www.arduino.cc/en/Reference/HomePage

I have read it and it simply explain the syntax not how it works. Or am I missing something.

em, i don't fully understand myself so maybe somebody else could explain the relevance of each.

So far i have only needed to send or receive bytes(0-255) for midi output or shift registers while i learn the basics.
In the example code you posted i don't understand how the analog value is interpreted, i know it is transmited in ascii but i dont know if the value is transmited like it would be typed in single digits(multiple bytes?) or some other way, the analog value(0-1023) would be larger than a byte.

byte 0-255
int 0-65000+
dec floating point number?
hex 0-f
the rest ??

What does baud 9600?? what does 9600 stand for??

this is the serial port speed & should match the serial object in max, other speeds can be used too, look at the serial monitor in the arduino IDE for other speeds you can use.

For the docs, download the windows zip from below & unzip, the reference folder is definitely inside.
http://www.arduino.cc/en/Main/Software

Lee