Asked
Resolved Resolved by Athena AI!

Ultrasonic Sensors Troubleshooting And Alternative

Here’s my project setup: I have a lawnmower that stays in a small garage. As soon as it moves outside, a camera mounted on the mower should rise using a scissor lift.

The lift should move up when the mower leaves the garage. My idea is to use an EZ-Robot ultrasonic sensor to measure the distance from the side walls:

If the distance is below 40 cm, the camera stays down.

Once the distance is above 40 cm, the camera moves up.

I’m currently testing the ultrasonic sensors, but the results are unreliable. Although they’re powered from 5 V (port D4 on an IoTiny), the readings are inconsistent - sometimes correct, sometimes wrong. I tested five different sensors, and none give stable measurements. I previously used the same sensors on an Arduino without any issue.

So, I tried something else: a Sharp IR sensor. I’m using the ADC Meter Skill and its variable $ADCMeter. Here’s the test script:

// Test IR Sharp Sensor in ARC

// Continually read the global variable $ADCMeter
while (true)

  // Get the variable value
  var x = getVar("$ADCMeter")

  // Print the current ADC value
  print("ADC value: " + x)

  sleep(1000) // pause for 1 second
endwhile

But I get this error:

Variable not defined: $ADCMeter

It seems the variable isn’t being read from the ADC Meter skill, even though it’s defined there.

Can you tell me what I’m doing wrong? And if you have other ideas for detecting when the mower exits the garage - maybe a better sensor setup than ultrasonic or IR - I’d love your advice.

Thanks,


Related Hardware EZ-B IoTiny
Related Controls Vertical Servo ADC Meter

ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

PRO
Canada
#9  

Glad to hear that it's helpful! Feel free to experiment with the filter size and the threshold values to perfectly match your sensor’s response. If you run into any issues or need further adjustments to the code, just let me know. Happy testing!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.