Pololu 3pi Robot User Manual

Page 53

Advertising
background image

int message[1];

unsigned int tmp_sensors[5];

int line_position;

if(pid_enabled)

line_position = last_proportional+2000;

else line_position = read_line(tmp_sensors, IR_EMITTERS_ON);

message[0] = line_position;

serial_send_blocking((char *)message, 2);

}

// Sends the trimpot value, 0-1023.

void send_trimpot()

{

int message[1];

message[0] = read_trimpot();

serial_send_blocking((char *)message, 2);

}

// Sends the batter voltage in millivolts

void send_battery_millivolts()

{

int message[1];

message[0] = read_battery_millivolts();

serial_send_blocking((char *)message, 2);

}

// Drives m1 forward.

void m1_forward()

{

char byte = read_next_byte();

if(check_data_byte(byte))

return;

set_m1_speed(byte == 127 ? 255 : byte*2);

}

// Drives m2 forward.

void m2_forward()

{

char byte = read_next_byte();

if(check_data_byte(byte))

return;

set_m2_speed(byte == 127 ? 255 : byte*2);

}

// Drives m1 backward.

void m1_backward()

{

char byte = read_next_byte();

if(check_data_byte(byte))

return;

set_m1_speed(byte == 127 ? -255 : -byte*2);

}

// Drives m2 backward.

void m2_backward()

{

char byte = read_next_byte();

if(check_data_byte(byte))

return;

set_m2_speed(byte == 127 ? -255 : -byte*2);

}

// A buffer to store the music that will play in the background.

char music_buffer[100];

// Plays a musical sequence.

Pololu 3pi Robot User's Guide

© 2001–2014 Pololu Corporation

10. Expansion Information

Page 53 of 63

Advertising