Problems with Arduino Robot (Lottie Lemon) & Ultrasonic Sensor SEN136B5B (solved

I am newbie with official Arduino Robot (Lottie Lemon) and I am newbie in others too :D. When I try to run the sample program I do not get it to work even when I modified the original program as

// read the value from the sensor
int sensorValue = Robot.digitalRead(sensorPin);

I use Ultrasonic Sensor SEN136B5B

This is my code:

// include the robot library
#include <ArduinoRobot.h>

int sensorPin = TKD5; // pin is used by the sensor

void setup() {
// initialize the Robot, SD card, and display

// draw a face on the LCD screen

void loop() {
// If the robot is blocked, turn until free
while(getDistance() < 40) { // If an obstacle is less than 20cm away
setFace(false); //shows an unhappy face
Robot.motorsStop(); // stop the motors
delay(1000); // wait for a moment
Robot.turn(90); // turn to the right and try again
setFace(true); // happy face
// if there are no objects in the way, keep moving
Robot.motorsWrite(255, 255);

// return the distance in cm
float getDistance() {
// read the value from the sensor
int sensorValue = Robot.digitalRead(sensorPin);
//Convert the sensor input to cm.
float distance_cm = sensorValue*1.27;
return distance_cm;

// make a happy or sad face
void setFace(boolean onOff) {
if(onOff) {
// if true show a happy face
Robot.background(0, 0, 255);
Robot.setCursor(44, 60);
Robot.stroke(0, 255, 0);
// if false show an upset face
Robot.background(255, 0, 0);
Robot.setCursor(44, 60);
Robot.stroke(0, 255, 0);

I use the same sensor with Arduino Uno and I have no problem.
Sorry for my bad English.

i think we have the same problem...
have you access to a oscilloscope?

Right now I can not have access to an oscilloscope, but I intend to get it after reading your post. As soon as I can and get the results I will comment on your post.

I managed to find a solution by using the following library:

Adapting the example R07_Runaway_Robot to my convenience.

I also have a problem with the wheels, the axis or the wheels are off center, I'm no expert in electronics although in programming, but I reach to be able to distinguish some servos or motors with poor quality and which have given the robot are :D.



I try to further progress in my project, but now I see a conflict between the libraries <ArduinoRobot.h> & <Servo.h> (both originally delivered with the IDE)

Robot_Control\Melody.cpp.o: In function __vector_17': C:\Program Files (x86)\Arduino\libraries\Robot_Control/Melody.cpp:7: multiple definition of __vector_17'
Servo\Servo.cpp.o:C:\Program Files (x86)\Arduino\libraries\Servo/Servo.cpp:103: first defined here

I have a feeling that we have a hard way...