3pi slave print _long

I’m using a 3pi as a slave and a baby “o” as a master, using your expansion board with the cutout for the LCD.
My question is can you print long to the LCD on the 3pi while it is being used as a slave?
I like to get feed back on the LCD when I’m testing out sensors but the LCD is on the 3pi and I can’t find examples of how to print distance or detect from a sensor to the slave LCD


Yes, you can print a long (4-byte) value to your 3pi’s LCD screen while it is being used as a slave. You would need to convert your number into a string of bytes representing ASCII characters on your Baby Orangutan, and then send it to your 3pi along with the command byte (0xB8 to print to the slave LCD) and string length. You can look at the slave_print function in the “Serial master program” section of the 3pi Robot User’s Guide for reference. To convert a number to a string, you can use itoa(), sprintf(), or write your own function.

- Amanda

Thanks for the help Amanda
I’ll work on this now that I have some where to start

OK I’ve tried and failed. I’m just an older novice would does not know much about c programing. I have a 3pi with a baby O mounted on an expansion board with a cutout for the LCD. I loaded the slave and master programs and everything works fine. What I did not know was that the LCD on the 3pi really is not used except for text after loading both programs. This really does not make sense to me. The master program sends info to the master LCD but why not the 3pi ? 1st off were would someone put and LCD on the expansion board? With what little I do know I’ve been able to hook up sensors both analog and digital for detection and they worked fine using the examples from the master code and your forum. But I have not been able to utilize the LCD . Could you please post some simple lines of code for the battery mv on the 3pi LCD that could be added to the master program.

Hello, Bill.

As a quick recap, it sounds like you have an m3pi robot with a Baby Orangutan B-328 attached to it. You have loaded our 3pi-serial-slave (or something similar) onto the 3pi, and you have loaded the 3pi-serial-master onto the Baby Orangutan. The issue is that you want to display a number on the LCD on the 3pi and you’re not sure how to modify the 3pi-serial-master code to achieve that.

I have not tested the function below, but you should be able to add it to 3pi-serial-master program and then call it in order to send numbers to the 3pi’s LCD. I recommend inserting this function right below the definition of slave_print:

void slave_print_long(long x)
    char buffer[12];
    sprintf(buffer, "%ld", x);

The 3pi-serial-master program can run on boards such as the Orangutan SV-328, which does have an LCD. If you are running it on a board with an LCD, it makes sense to use that LCD to help debug the program.


I inserted your code into the serial master program using AtmelStudio and the following 2 warnings came back
Warning 1 implicit declaration of function ‘sprintf’ [-Wimplicit-function-declaration]
Warning 2 incompatible implicit declaration of built-in function ‘sprintf’ [enabled by default]
I don’t know what it means but thanks for trying

Can you try adding this near the top of the file where you inserted that function?

#include <stdio.h>


OK that did it thanks a lot