How can i connect the QTR8A to Orangutan SV-328

I want to know how about the port and How can I read the sensor
thank you :smiley:

Hello.

You can use the Pololu AVR library to interface your Orangutan with the your QTR sensors, and you can look at the library source code if you’re interested in how it works. For more information, see:

pololu.com/docs/0J20/6.k
pololu.com/docs/0J18/16

- Ben

if i want to contact to all of 8 sensors in QTR sensor to built line follower robot That code is ok?
i try to use ex. code :smiley:

#include <pololu/orangutan.h>

int main()
{
  unsigned char qtr_rc_pins[] = {IO_D0,IO_D1,IO_C0,IO_C1,IO_C2,IO_C3,IO_C4,IO_C5};
  qtr_rc_init(qtr_rc_pins, 8, 2000, 255); 
  int i;
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds
  {
    qtr_calibrate(QTR_EMITTERS_ON);
    delay(20);
  }
  print("calibrat finish");
 
  while (1)
  {
  	loop();
  }
 
  return 0;
}

int lastError = 0;
 
void loop()  
{
  unsigned int sensors[8];
  int position = qtr_read_line(sensors, QTR_EMITTERS_ON);
  int error = position - 1000;

  int KP = 0.1;
  int KD = 5;

  int motorSpeed = KP * error + KD * (error - lastError);
  lastError = error;
  
  int M1 = 100;
  int M2 = 100;

  int m1Speed = M1 + motorSpeed;
  int m2Speed = M2 - motorSpeed;
 
  if (m1Speed < 0)
    m1Speed = 0;
  if (m2Speed < 0)
    m2Speed = 0;
 
}

It might be… Before I spend a while looking at it, can you tell me if it actually works?

- Ben

It ok but notwell i must tune it

That’s to be expected. It sounds like it’s doing something, so I think you’re on the right track.

- Ben