Grasshopper

algorithmic modeling for Rhino

Hi all,

I'm trying to work with an Arduino and as input I'm using a infrared sensor. Every time something interrupts the infrared beam I get the value true of false. I'm looking for something to create a loop calculation.


I found Hoopsnake, but it hasn't worked for me jet. I'm trying to found a counter that counts the times the value switches from true to false.

Anyone that can help me out?

Thanks,

Arie 

Views: 693

Replies to This Discussion

Can you be more specific than 'loop calculation'? What are you looking over? What do you want to do each iteration?

I've got a sensor which gives the signal true or false. Every time it switches from true to false I want to add 1. 

Example: I start with 0, i move my hand across the sensor and it tells me false, at this moment I want to add 1 to the starting value, but now the starting value should be set to 1. The next time i move my hand across the sensor it should add 1 to the previous value.

I tried using Hoopsnake in the example by switching the toggle button, but its not giving me any result.

Attachments:

Try this.. Maybe its too simple though, as just based on your explanation and not your code.

Attachments:

For limited (a few thousand or less) values, you can get away with a data recorder and the Delete Consecutive component.

However if your sensor is spitting out 50 values per second and you want to record 6 hours worth of data, it's obviously not a good idea to keep all values forever. In that case you'll need some custom code that's smart enough to decide when it makes sense to store a new value in a permanent record.

To get your final tally you just need a List Length component at the very end. That'll tell you how often the value has changed.

Attachments:
Great, this does seems to do the trick!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service