Grasshopper

algorithmic modeling for Rhino

Hi,

i am trying to use a arduino uno with a ping sensor (HC-SR04) and firefly. 

The problem is, that i only have the components uno write and uno read. As far as i understand ping sensors, i need a component wich can do both - to send a signal and to receive a signal, to measure the time the signal traveled

How can i do that in firefly?! there must be a solution, because other people have done that too!

i connected Trig& Echo to dpin2. the code i used to test the sensor was:


const int pingPin = 2;

void setup() {
Serial.begin(9600);
}

void loop()
{

long duration;

pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, HIGH);
digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);

duration = pulseIn(pingPin, HIGH);

Serial.print(duration);
Serial.println();

}

The output was like i expected. So now i am sure, that the sensor works.

How can i do that in firefly?!?

Or is there no way?

Any ideas would be great!!!

Thanks!

Views: 2853

Replies to This Discussion

Hey, i found the solution: i implemented the feature into firmata. 

it only works if its an arduino uno, and the sensor is connected to the Dpin2. 

It outputs the distance to the Sensor in cm.

Thanks!

Attachments:

Hello!

Can you send the definition of grasshopper

to work with your Arduino definition?

Thanks!

Nice.  I've been waiting for my sensor to come in the mail... but I look forward to testing out your solution.  Thanks for the contribution.

Hi!

The code works as you described. It is great. 

Just wonder if it is possible to do that in multiple pins?

Thank you!

hi!

i've been trying out your custom firmata for ultrasonic range sensors (i tried the parallax one and the radio shack one). it works great for exactly what you said it would: sensing range.

but i wanted to move a servo based upon that range too. for some reason your custom firmata keeps the servo from functioning at all. if i reload the standard firmata for firefly the servo works fine again, but not the range sensor... this has been tested on several computers and several sensors and arduinos with the same effect.

i'm quite a noob with all this stuff, so apologies if the answer is a very obvious or simple one... but is there a way to have my servo cake and eat sensors too?

thanks for any help you can provide!

mart

hello Mart, i have exactly the same problem as you, did you solve this already?

Thank you

Jaime

Hello, 

I have been trying to get the data using the code Firefly_Firmata_ping.ino Firefly_Firmata_ping.ino uploaded by J Flölich however in Grasshopper, I can not obtain any useful data from the uno read component.

As the sensor is plugged into Digital Pin 2 as instructed, the distance is supposed to be seen when a panel is linked to DPin2 on UnoRead component. What is it that I am doing wrong?

Thanks,

hey Cemre! I guess i had the same problem as you! you need to plug both pins (TRIG and ECHO) into port two then it should work. Cheers

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service