Asked
Resolved Resolved by Athena!

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 (view all EZB hardware)
EZ-B Iotiny by EZ-Robot
Control IoTiny with Synthiam ARC: 100MHz Cortex‑M4 Wi‑Fi IoT/robot controller-camera, servos, ADC, I2C and digital I/O for easy internet automation
Wi-Fi / USB
Servos 8
Camera
Audio
UART
I2C
ADC
Digital

Related Robot Skills (view all robot skills)
Vertical Servo by Synthiam
Drag vertically to control a servo within set min/max limits; center, release, invert, and mirror to other servos. For 3-wire GVS servos.
ADC Meter by Synthiam
ADC VU meter displaying 0-3.3/5V as a 0-255 linear meter; configurable board/port, sampling interval and color; pausable real-time readings.

ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

Author Avatar
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.