Rank: Newbie
Groups: Registered
Joined: 3/7/2015(UTC) Posts: 4
|
I'm testing your application, I've been watching the tutorials, but I still don't understand how to "convert" or use the software with the utrasonic sensor at this moment I have the echo in the pin 8 and the trig in the pin 9I tested different ways, taking as reference the IR distanse tutorial, but I have not succeed getting the values from my sensor (if I do in arduino's IDE it works) can anyone help me? thanks in advance! PD: I'm using Arduino MEGA Edited by user Saturday, March 07, 2015 9:48:09 PM(UTC)
| Reason: adding more info
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 109 time(s) in 104 post(s)
|
To make sure your connection to the Arduino is working, can you go through the built in blink tutorial and confirm that you can turn on and off the built in LED? http://embrio.io/project...jects/blink-built-in-ledThere's not enough info in your post for me to go by, could you zip up your project and attach it here? On the root node of the project tree you can right click and select "Open Folder Location" to easily get to where the project is saved. Edited by user Sunday, March 08, 2015 5:59:42 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/7/2015(UTC) Posts: 4
|
Sorry about that I tested the Led example and it works fine. that is how the sensor is connected this is the sketch that I upload in the Arduino IDE Code:
long distance;
long timer;
void setup(){
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(8, INPUT);
}
void loop(){
digitalWrite(9,LOW);
delayMicroseconds(5);
digitalWrite(9, HIGH);
delayMicroseconds(10);
timer = pulseIn(8, HIGH);
Distance = int(0.017*timer);
Serial.println("Distance ");
Serial.println(distance);
Serial.println(" cm");
delay(1000);
}
Edited by user Sunday, March 08, 2015 12:57:12 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 109 time(s) in 104 post(s)
|
You'll have to use a "Custom Arduino Node", check out this video for the concept: http://www.embrio.io/pro...ner-projects/hobby-servoI'm currently working on a library of built in custom nodes that users can submit new ones to, and better documentation for this feature, so in a week or so this will be even easier. Your custom node would look something like this: The transform() function is a built in function. Embrio values are all from 0.0 to 1.0, so you need to transform your value before setting the output activation. Change the 100 seen in the screenshot, the 3rd parameter, which is the input range max, to whatever the highest value for your distance value would be.
|
1 user thanked EmbrioAdmin for this useful post.
|
|
|
Rank: Member
Groups: BetaUser, Registered Joined: 2/7/2015(UTC) Posts: 17
Thanks: 4 times
|
The code above is working, but now Embrio gives error: "When using the pulseIn function in Embrio you should use the 3rd parameter to set a timeout. Put as low a timeout as you can for your situation. With no time out, the function could hang and prevent the rest of your program from running."
If I set timeout in pulseIn(8, HIGH, timeout); node stops working again.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 109 time(s) in 104 post(s)
|
Replace the word "timeout" with an actual value, try 1000 first.
The pulseIn function could end up waiting for a long time if it doesn't get a value, like if there's nothing plugged into the pin. If this happens, it'll mess up the execution of the compiled program, which will just stop waiting for the pulseIn to finish. To prevent this, use the 3rd parameter to give it a maximum time to wait for a value. I'm not actually sure how long the ultrasonic sensor's pulse will be, 1000 microseconds might be too low. I don't have one of those sensors to test, so you might have to experiment a little.
|
|
|
|
Rank: Member
Groups: BetaUser, Registered Joined: 2/7/2015(UTC) Posts: 17
Thanks: 4 times
|
Thank you. Issue is over. I've managed to get data from sensor. Edited by user Friday, March 27, 2015 10:24:11 PM(UTC)
| Reason: Not specified
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.