Grasshopper

algorithmic modeling for Rhino

I have a sketch set up in Arduino so that motors move in the X,Y,Z directions when the string 'X', 'Y', or 'Z' are typed into the serial monitor.  This is working well from processing, but I can't get this to work with the Serial Write from grasshopper.  I noticed here that there may be some formatting involved.  Is there a quick and easy way for Arduino to read what's coming from Grasshopper?  

In other words, I want to know how the data from Grasshopper can cause the same outcome as if I opened up the Serial Monitor in Arduino, typed in X, and hit Enter.


Thanks for any help.

Erick

Views: 529

Replies to This Discussion

Hey Erick,

Have you looked at the IsKeyPressed component?  You have to use a timer, but you can specify any key (or combinations of keys, by using a mass addition on the output) and it will return a boolean if the key was just pressed.  Then, using that boolean, you can decide to write whatever data using the Uno Write (or Generic Serial Write).  Would this work for your application?

Best,

Andy

Hey Andy,

I'm actually just trying to get a way for the arduino Serial Monitor to read the string "x".  My first test was to put "x" into a string and plug that into the data port of the serial write.  The arduino board blinks so it's getting an input of some sort, but it's not triggering the if(key=="x") command from the arduino IDE.  I'm wondering if there's additional syntax to put into the data port in Grasshopper, or if I need to parse the code some way in Arduino.

Erick

Hi Erick,

I'm sorry for the late reply... I only just saw your message.  In order for the Arduino board to take some sort of 'action' based on a key press, you need to parse up the incoming data and tell it to do something.  If it's just a single character, it's a little easier... but if it's a comma separated set of values, then you have to walk through the incoming character string, placing each character into a temporary buffer... and when it encounters a delimeter (comma) then dump the buffer into a variable.  This is basically what the Firefly Firmata does.  Check out the ReadSerial() function.

Does this help?

-Andy

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service