StandardFirmata works perfectly on the Mega with my inputs for 1-12, but I feel like I need to modify the code to account for the remaining pins. Maybe my initial description was unclear, and if so, I apologize. How do I detect a button push on pin 22 and have Processing call "runThisMethod() "? From what you are describing, it sounds like all of my reads and writes are handled on the Arduino side of things, when in reality, I want to call methods within my Processing sketch as changes are made to what's hooked up to the Arduino board. ![]() Let's use the basic code below as a simple example instead. That gives me somewhere to start, although I'm still having issues because my Processing sketch is massive. If the encoder generates a lot of pulse close together, so that you need to use interrupts to deal with all the pulses, then reading the encoder value requires another command, and the value that was returned might be old before the transmission was complete. Implementing it isn't all that challenging, either, for simple things. Defining a protocol is relatively simple. If(index " to write a 0 to pin 35, or "" to set the mode of pin 22 to INPUT. Read all serial data available, as fast as possible If Processing were to send something like "", the Arduino could run code like this: #define SOP '' First, what are the options for more than 12 digital I/O pins with Arduino, or how is it possible with the Mega? Second, if I proceed with the Mega, what's a simple example of a digitalRead(), digitalWrite(), or otherwise on pins 22-53? Again, there aren't many examples or substantial libraries that accomplish this from what I found.įorgive me for asking this for what may seem like the thousandth time, but I am very new to the world of Arduino. I found the Mega pin chart, but I don't know if I need to write my own protocol in Arduino to handle my I/O, or if there is a way to read and write to a Mega directly in Processing. I browsed the web and found a few threads explaining how the StandardFirmata is not compatible with the Mega, and that the pin mapping of the Mega differs from that of the Duemilanove. ![]() Now I'm at a bit of a loss as to how to read and write to the Mega from my Processing sketch. This worked fine until I reached a point when I wanted to add more rotary encoders and a button, but with no more digital pins available, I decided to purchase a Mega. Previously, I loaded the StandardFirmata on the Duemilanove and hooked up a series of rotary encoders and a joystick on pins 1-12 to control a Processing sketch that I am working on. I did not realize that the StandardFirmata does not work with the Mega, rendering the additional pins 22-53 unusable unless I write my own protocol, from my understanding. I recently purchased an Arduino Mega 2560 because I felt that my I/Os were limited on my Duemilanove.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |