Hi, I have to improve Bittle with a infrared distance sensor, for a school project.
I pluged the sensor on the +5V, GND and A3.
I need to know in which file I have to write the code for adding the sensor.
Thanks for your help.
Clem, student from France
In src/io.h, add this line:
void readDistance() { int Leftdistance = 4800 / (analogRead(Leftsensor) - 20); //converting in centimeter int Rightdistance = 4800 / (analogRead(Rightsensor) - 20); if (0 < Leftdistance < 20) { strcpy(newCmd, "wkR"); token = T_SKILL; newCmdIdx = 5; } else if (Leftdistance > 60 or Leftdistance < 0) { strcpy(newCmd, "wkL"); token = T_SKILL; newCmdIdx = 5; } }
Could you help me please, could you write the begginig of the code.
Thanks
Hello, I come back to you because I've try to make the code and I think I'm bad for that. It doesn't work.
I've two infrared sensor, one for the left side, the other one for the right. The left sensor is pluged on A2, the right on A3.
the code in ultrasonic.h:
int Leftsensor=A2; int Rightsensor=A3; void loop() { int Leftdistance = 4800/(analogRead(Leftsensor)-20); //converting in centimeter int Rightdistance = 4800/(analogRead(Rightsensor)-20); if (0 < Leftdistance < 20){ strcpy(newCmd,"sit"); } else if (Leftdistance > 60 or Leftdistance < 0){ strcpy(newCmd,"sit"); } //same for the right side }
this code code doesn't work,
in addition I would like those instructions work only when Bittle walk forward
I hope you will help me
ok, used kcalib in serial monitor and recalibrated.. things seem good now..
ok, yes, I redownloaded the code with the change you made about 40 minutes ago and the odd behavior has been resolved. Now when I send the kzero command I do need to recalibrate. I am guessing there might be a bug where it does not go into calibration mode after saying yes to reset joint offsets. If there is another way please let me know... Thanks...
The code uploaded 24hours ago has a bug. So I uploaded a new one today. Please try it and redo the writing steps.
So I was able up upload everything just fine. During the first stage with #define MAIN_SKETCH commented out I get to "Reset joint offset?" at first I said no because I figure this would bring it into calibration mode. After I realized it does not go into calibration mode, but you are required to say yes in order for the skills to load.
The sounds and improvements on the Calibrate the IMU are great!
I go back and uncomment the main sketch but when it's done uploading Bittle jerks into an odd position, the front legs straight down and the read legs bent forward are a 90 degree angle at the lower joint. After any command I try results in very odd movement. My thought it maybe I need to recalibrate, but since saying yes at reset joint offsets doesn't go into calibration I'm not sure how to do it.
Any ideas on any of this?
Also, should we be updating things when Arduino says there are updates?