Configuration

and how to use the PID? My 3pi this with a good time however I know that could improve

I am using the following program
- YouTube) … j8_-iyz2zQ)

My LCD does not work will be I did something wrong?

#include <pololu/3pi.h>
#include <avr/pgmspace.h>
#include <pololu/orangutan.h>
#include <pololu/qtr.h>
#include <pololu/encoders.h>
#include <pololu/analog.h>
#include <pololu/buzzer.h>
#include <pololu/time.h>
#include <pololu/motors.h>
#include <pololu/lcd.h>
#include <pololu/leds.h>
#include <pololu/pushbuttons.h>
#include <pololu/serial.h>

const char welcome_line1[] PROGMEM = " Pololu";
const char welcome_line2[] PROGMEM = "3\xf7 Robot";
const char demo_name_line1[] PROGMEM = "Line";
const char demo_name_line2[] PROGMEM = "follower";

const char welcome[] PROGMEM = ">g32>>c32";
const char go[] PROGMEM = "L16 cdegreg4";

const char levels[] PROGMEM = {
   0b00000,
   0b00000,
   0b00000,
   0b00000,
   0b00000,
   0b00000,
   0b00000,
   0b11111,
   0b11111,
   0b11111,
   0b11111,
   0b11111,
   0b11111,
   0b11111
};

void load_custom_characters()
{
   lcd_load_custom_character(levels+0,0);
   lcd_load_custom_character(levels+1,1);
   lcd_load_custom_character(levels+2,2);
   lcd_load_custom_character(levels+3,3);
   lcd_load_custom_character(levels+4,4);
   lcd_load_custom_character(levels+5,5);
   lcd_load_custom_character(levels+6,6);
   clear();
}

void display_readings(const unsigned int *calibrated_values)
{
   unsigned char i;
   
   for(i=0;i<5;i++) {
      
      const char display_characters[10] = {' ',0,0,1,2,3,4,5,6,255};
      
      char c = display_characters[calibrated_values[i]/101];
      
      print_character(c);
   }
}

int integral;
int last_proportional;

void initialize()
{
   unsigned int counter;
   unsigned int sensors[5];
   
   pololu_3pi_init(2000);
   load_custom_characters();
   
   print_from_program_space(welcome_line1);
   lcd_goto_xy(0,1);
   print_from_program_space(welcome_line2);
   play_from_program_space(welcome);
   delay_ms(1000);
   
   clear();
   print_from_program_space(demo_name_line1);
   lcd_goto_xy(0,1);
   print_from_program_space(demo_name_line2);
   delay_ms(1000);
   
   while(!button_is_pressed(BUTTON_B))
   {
      int bat = read_battery_millivolts();
      
      clear();
      print_long(bat);
      print("mV");
      lcd_goto_xy(0,1);
      print("Press B");
      
      delay_ms(100);
   }
   
wait_for_button_release(BUTTON_B);
delay_ms(1000);

for(counter=0;counter<80;counter++)
{
   if(counter < 20 || counter >= 60)
   set_motors(40,-40);
   else
   set_motors(-40,40);
   
   calibrate_line_sensors(IR_EMITTERS_ON);
   
   delay_ms(20);
}
set_motors(0,0);

while(!button_is_pressed(BUTTON_B))
{
   unsigned int position = read_line(sensors,IR_EMITTERS_ON);
   
   clear();
   print_long(position);
   lcd_goto_xy(0,1);
   display_readings(sensors);
   
   delay_ms(100);
}
wait_for_button_release(BUTTON_B);

clear();

print("Go!");

play_from_program_space(go);
while(is_playing());
}

int main()

{
int last_proportional;
   unsigned int sensors[5];
   
   initialize();
   
   while(1)
   {
      unsigned int position = read_line_white(sensors,IR_EMITTERS_ON);
      
      if(position < 1000)
      {
         
         set_motors(35,155);
         
         left_led(0);
         right_led(1);
      }
      else if(position < 3000)
      {
         set_motors(150,150);
         left_led(0);
         right_led(0);
      }
      else
      {
         set_motors(155,35);
         left_led(1);
         right_led(0);
      }
   }
   
}

Hello.

The YouTube link you posted does not work because it has “…” in it. You might want to try posting that again.

Did you try turning the contrast potentiometer on the bottom of the 3pi to different positions, as I suggested in my last post? The LCD might just be blank because the contrast is set too low.

To use PID for linefollowing the 3pi, you should start with our 3pi-linefollower-pid example code. If that example works for you and you want your 3pi to go faster, you should try increasing the “max” variable, but you will also need to tune the constants on the line that computes the “power_difference” variable or else your 3pi will have trouble staying on the line.

–David