I2c Ezb Arduino1 Sensor

Luis Vazquez

USA

Hello all,

I wail back I posted some information on using an Arduino as a I2C Sensor controller to use with the EZB3&4

I will post this in 3 stages ..

Stage one.. right here right now.

In this video you can see how im using the arduino to read the ultrasonic sensor . that in turn is being read by the EZB board via I2C.

This is the only code needed to read the ping for the EzBuilder script


print(I2CRead(0, 2,6 ))

The code for the Arduino is



#include 

void setup()
{
  Wire.begin(2);                
  Wire.onRequest(requestEvent); 
}

void loop()
{
  delay(100);
}

void requestEvent()
{

  long duration, inches, cm;
  pinMode(9, OUTPUT);// attach pin 3 to Trig
  digitalWrite(9, LOW);
  delayMicroseconds(2);
  digitalWrite(9, HIGH);
  delayMicroseconds(5);
  digitalWrite(9, LOW);

  pinMode (8, INPUT);//attach pin 4 to Echo
  duration = pulseIn(8, HIGH);
  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  
  String outtoezb;
  
  outtoezb +=  "D1=";
  outtoezb += inches;
  outtoezb += ":";
  
  char  tempout[outtoezb.length() + 1];
  outtoezb.toCharArray(tempout,outtoezb.length() + 1); 
  Wire.write(tempout); 
}

long microsecondsToInches(long microseconds)
{
  
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  
  return microseconds / 29 / 2;
}


Phase two will be adding the 3 other ping sensors and a temp sensor to the arduino . I hope to have it all encased together will plugs and off the project board.

I will follow up on this thread as the next phase is done I will provide the code for EzBuilder as well as the arduino code.

Hope yall can use it.

By — Last update

ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

#9  

The concept rover is a Jazzy Wheel Chair base, and the Sabertooth dual 60A motor driver, is on this weeks shopping list:) Were up in the air on the final design, now after playing with the option of incorporating a Fifth wheel design, with the trailer style unit to house the educational platforms., including solar power, but this is a year out. Ive also contemplated incorporating an Arduino on the main system for back up in case of loss of signal, or PC failure, so the rig doesn't go dark/dumb on me.

#10  

Actually... that's a good use for the arduino... If the ezb should lose connection an arduino can be programed for an "elegant safe" shutdown sequence... Nice

#11  

@Luis Vazquez Hi Luis, im working with your Arduino code, and running into a few problems. Obviously you have had this running, so not sure where the errors are coming from. Im using V 1.0.6 any chance it may have to do with version?

User-inserted image

#12  

Hello Dana, I have been off the forums for a bit. Someone told me you were having some issue.. I will be happy to help any way i can. It looks here like you are missing the Wire Library.

It should be included in your arduino editor. Here is a like to the library information. though I'm not sure right off where to download it other than it comes with the Arduino Editor.

Wire Reference from Arduino

If you need more help please let me know.

#13  

I love the EZB and it solved lots of problems face the by the robot builder but truth this it is not gods give to robotics and I encourage anyone to experiment with other controllers as in combination they can come up with something actual ground breaking. I have stop participation on this forum because of that reason. I am working with other forums that are interested in building robots , no mater how you have to do it. seem this is a use ezb or get out kinda forum.

#14  

Luis,

Sorry to see you aren't participating here anymore. Obviously, as a company owned forum, the primary focus will be their product, but I think what you have done in combining the capabilities of EZ-B with other controllers to extend the functionality is brilliant, and I for one will miss your participation.

Could you let us know where you are participating? I am always interested in broadening my horizons.

Alan

#15  

OK, thank you very much Luis! Thanks for stopping by:) Much appreciated. Would love to know of other good forums, since the nature of the project I'm working uses multiple platforms. I think your right on the Library, I'm going to reinstall the IDE to see if it helps, since i would expect it to be there as well, thanks again:)

"If your not having fun, your not doing it right!"

#16  

Hey Luis

I second what Alan said. I miss your input and the projects you shared with us. To me (my opinion) the idea of using the Arduino or any other microcontroller with the EZB is a great idea. Would like to continue seeing your work and hearing of any new ideas you have.

If you read this, Please send me a email so I can keep in touch with you!

Old-FireFighter138(at)neo(dot)rr(dot)com

Thanks