How to set Maxuino analog and digital pin modes separately?
I’m working for the first time with Maxuino and it all works fine, but I don’t see anywhere how to set analog pin modes separately from the digital ones. For example, on an Arduino Mega, I have analog pins 0-15 and digital pins 0-52. If I send a message that says (/5/ mode 2), how does it know if I want to do that to analog pin 5 or digital pin 5? When I look at [maxuino-gui] I see visually that the analog pins can only be turned on and off, not have their modes set. But how do I send it a message to turn on a specific analog in?
afaik you can identify analog pins with A0, A1 etc
does that help? Not familiar with Maxuino or Arduino libraries
You set the digital pinmodes in the right part of the GUI (or in the separate ‘pinmode’ patcher.)
If you want an analog in you just send the message you said (/5/ mode 2). I guess maxuino knows that mode 2 only applies to analog pins, and mode 0/1 only apply to digital pins.
I personally found maxuino/firmata to be super clunky and difficult to "use" so I just with with serial.print on the Arduino and the [serial] object in max. It took a bit to get it going, but at least I know what does what. (There’s a good example in the Arduino IDE called "VirtualColorMixer" under examples/communication, that has some max code in there to copy/paste)
Rodrigo – I was wondering if that might be the case, but when I try do do that with the included maxuino.help patch I can’t get it to work. In the [pin-modes] patcher I set a pin to analog in and then look at it in the [Analog-Digital-Inputs] patcher and nothing happens. If I manually open [maxuino-gui] and click on that analog pin to change its state from off to on then it will start reading from it perfectly.
There has to be some way to access it other than manually. In some of the examples I see /*/ and I’m trying to figure out if the asterisk has something to do with it.
Re: using [serial] and serial.print… If it were just me, I’d probably be doing that, but I’m trying to teach this to people with no coding knowledge and don’t have time to teach it. They know Max, so I’m trying to limit the new stuff to circuitry and interfacing Max with Arduino, but always from within Max.
Anybody have any suggestions?
Hmm, actually, Rodrigo, it appears that you were right. I think it was getting confused because I had the help patches open and the patch I was working on at the same time. When I restarted Max it worked. Indeed, sending it a (/5/mode 2) message activates analog pin 5 and sending it a (/5/mode 1) message makes digital pin 5 a digital out. I can use both in the same patch and it knows which one I’m talking about. At least that’s how it seems so far.
That makes sense if you’re not used to arduino. Depending on the scope of what you’re trying to teach you could just write up an Arduino sketch (if you know what pins you plan on using) and the appropriate max patch, that way people can actually ‘see’ what’s happening.
I also found it odd that you couldn’t send the /2/ mode 2 to the maxuino object directly, it had to go to the gui.
There’s also this, which got me started on the path of using [serial] in max:
Forums > MaxMSP