HMC5883 Compass icon HMC5883 Compass Reads HMC5883 3-axis compass via I2C and updates EZ-Script variables on demand; polled control offers periodic heading data, for connected sensors. Try it →
Asked — Edited
Sharp IR on car robot, table top robot avoids falling off

Sharp IR On Car Robot, Table Top Robot Avoids Falling Off

anyone know how to write this code in java?

:loop adc_wait(adc0,lower,160) stop() reverse(200,500) sleep(50) left(255,500) stop() forward() sleep(50) goto(loop)

now it starts, avoids falling off table, turns left, keeps going - cheers! All figured out below, I solved it below with help of thetechguru

thanks



Related Hardware (view all EZB hardware)
EZ-B V4 by EZ-Robot
EZ-B v4/2 robot controller: dual Cortex ARM, Wi-Fi, audio/video, 24 servo/digital ports, I2C/UART, camera and Synthiam ARC control for custom robots
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

Related Robot Skill (view all robot skills)
Infrared indoor positioning for ARC robots: dual-camera tracks IR beacon, shows real-time heading, path and EZ-Script navigation variables

ARC Pro

Upgrade to ARC Pro

With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.

Author Avatar
PRO
USA
#17   — Edited

Sharp IR sensor - ARC

figured it out - now it starts, avoids falling off table, turns left, keeps going  - cheers!

:loop adc_wait(adc0,lower,160) stop() reverse(200,500) sleep(50) left(255,500) stop() forward() sleep(50) goto(loop)

User-inserted image

User-inserted image

How would you write this code in java? EzAng

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#18  

Synthiam ARC doesn't work with Java - at least not without a ton of work. You'd need to create some bridge between the two compiled executables.

Also, I don't think those sleep(50) lines are doing anything.

Author Avatar
PRO
USA
#19  

I ment Java script

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#20   — Edited

This is probably a good way to back away from cliffs...

JavaScript Code


while (true) {

  // Wait for ever until the sensor is lower than 160
  // meaning a cliff was detected
  ADC.waitForLower(adc0, 160);

  // start moving back at speed 200
  Movement.reverse(200);

  // Continue moving back until the cliff sensor
  // no longer detects the cliff
  ADC.waitForHigher(adc0, 160);
  
  // And continue back a little more just in case
  sleep(1000);

  // Stop moving cause we're safe
  Movement.stop();    
}
Author Avatar
PRO
USA
#21  

thanks DJ for the code

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#22  

Actually this makes more sense if using any NMS skills for navigating..


while (true) {

  // Wait for ever until the sensor is lower than 160
  // meaning a cliff was detected
  ADC.waitForLower(adc0, 160);

  // Instruct any  NMS navigation that we're pausing
  Navigation.SetNavigationStatusToPause();
  
  // start moving back at speed 200
  Movement.reverse(200);

  // Continue moving back until the cliff sensor
  // no longer detects the cliff
  ADC.waitForHigher(adc0, 160);
  
  // And continue back a little more just in case
  sleep(1000);

  // Stop moving cause we're safe
  Movement.stop();    
  
  // Resume any  NMS Navigation
  Navigation.SetNavigationStatusToNavigating();
}
Author Avatar
PRO
USA
#23   — Edited

My problem was - I have a Sharp IR distance sensor, I need a Sharp Infrared Proximity Distance Sensor, ordered it

Author Avatar
Portugal
#24  

What is a the diference between "Sharp Infrared Proximity Distance Sensor" and "Sharp IR distance sensor"?