top of page

General Discussions

Public·224 members

Add an infrared distance sensor on Bittle

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

238 Views

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;
  }
}




About

Discussion, maintenance, and community building!

bottom of page