Libpololu-arduino with Uno

Dear Team
I am using libpololu-arduino library to build my robot

I am using 3pi PID Simple line follower arduino code

So I need to connect another Arduino Uno board to my robot which has been 3pi code uploaded

As per my program I sent the Letter ‘A’ from 3pi code uploaded Arduino board to another Arduino board and once the Letter 'A: received by the another Arduino board then LED connected to pin 13 should blink

I used Serial.begin(9600); both program and tested but it does not working
I already connected Rx pin to Tx pin and Tx pin to Rx

Few Codes from 3pi code uploaded board

void loop()
{
  Serial.begin(9600);
  Serial.println('A');
  // Get the position of the line.  Note that we *must* provide
  // the "sensors" argument to read_line() here, even though we
  // are not interested in the individual sensor readings.
  unsigned int position = robot.readLine(sensors, IR_EMITTERS_ON,1);



Full Codes for Second Arduino board

char x;
void setup() {
 Serial.begin(9600);
 pinMode(13,OUTPUT);
}

void loop() {
  if(Serial.available() > 0){
     x = (char)Serial.read();
    Serial.println(x);
    }
    if (x == 'A'){
      digitalWrite(13,HIGH);
      delay(500);
      digitalWrite(13,LOW);
      delay(500);
      
      }
      
      
}

Please advice

Hello.

It sounds like you have two Arduino Uno boards connected together via serial. Is that correct? Can you post pictures clearly showing how everything is connected in your setup?

Can you make sure you have a common ground connection between the two Arduino boards and try replacing your Serial.println commands with Serial.write? Also, in your code for the first Arduino board, you should move Serial.begin(9600) to the top of the setup() function so that you are not repeatedly reinitializing serial communication between the two Arduino boards.

- Amanda

Thanks for the reply

I connected both boards and now signals are receiving but like unknown Chartres as well as board rate mismatch but I set both board board rate same

char x;
void setup() {
 Serial.begin(9600);
 pinMode(13,OUTPUT);
}

void loop() {
  if(Serial.available() > 0){
     x = (char)Serial.read();
    Serial.println(x);
    }
    if (x == 'A'){
      digitalWrite(13,HIGH);
      delay(500);
      digitalWrite(13,LOW);
      delay(500);
      
      }
      
      
}
void setup()
{
  Serial.begin(9600);
  Serial.println("A");
  unsigned int counter; // used as a simple timer
void setup()
{
  Serial.begin(9600);
  Serial.write("A");
  unsigned int counter; // used as a simple timer

 Serial.begin(9600);
  Serial.write('A');
  unsigned int counter; // used as a simple timer

Please see the attached for better understand

It’s difficult to see some of your connections between the two Arduino boards, but it looks like you might be connecting the 5V line from one Arduino to the other. If so, you should not do that if both boards are powered through USB since it could damage the on-board regulators. You should remove that wire and measure their voltages using a multimeter to verify that they’re still outputting 5V.

Can you post screenshots of the serial terminals showing the problem?

- Amanda

Please find the screen shop

%v Line is removed but same issue

Please help

It seems like there is a problem with your other code; you’re probably not sending values in the correct format (or handling them properly). I suggest simplifying your code on both your boards, where one is just transmitting a character (e.g. ‘A’) and the other is receiving, verifying that your boards are able to communicate with each other. Once you get that working, you can gradually modify the transmitting code to look like your original code.

- Amanda

I simplified the code as showing below and tested but no success



// The following libraries will be needed by this demo
#include <DcubeRobot.h>
#include <PololuQTRSensors.h>
#include <DcubeMotors.h>
#include <DcubeAnalog.h>
#include <DcubeLEDs.h>
#include <DcubeLCD.h>
#include <DcubePushbuttons.h>
#include <DcubeBuzzer.h>

// Board Selected as "Pololu Orangotan or 3pi robot w/ATMega329P"
void setup()
{

  //Serial.begin(9600);
 // Serial.begin(19200);
  Serial.begin(115200);
}
void loop()
{

  Serial.println("A");
  //Serial.write("A");
  //Serial.println('A');
  //Serial.write('A');

}


When I connected both board with Arduino bootloader then everything work perfect but only issue one board selected as pololu oranotan or 3pi 326p and program it using ICSP

Is there any special library to include to libpololu-arduino library for Serial Communication

You should not be trying to program your Arduino boards as an Orangutan or a 3pi. The Orangutan and 3pi were not designed as official Arduino boards, and run at 20 MHz instead of 16 MHz, so when you select “Pololu Orangutan or 3pi robot w/ ATmega328P” in your Arduino IDE, the Serial library assumes it is running on a 20 MHz board when you are actually running on a 16 MHz board, causing it to use the wrong baud rates.

- Amanda

What is the “Pololu Orangutan or 3pi robot w/ ATmega328P” board rate selected for 20MHz and do you have the experience solution for this

Most Honestly: As long as the BAUD rates are both the same, it will work.

As I said in my previous post, for your setup, you should not be trying to program your Arduino boards as an Orangutan or a 3pi. I recommend selecting “Arduino/Genuino Uno” in the “Board” menu of the Arduino IDE.

- Amanda

Once we select the board as a Arduino/Genuino Uno the it fail to compile

Can you enable verbose output in the Arduino IDE and post a copy of the entire output here? You can turn on verbose output by selecting File->Preferences in the IDE, and then checking the “compilation” and “upload” boxes next to "Show verbose output during: ".

- Amanda

Thanks for the reply

Following errors display once we select the board as Arduino/Genuino/Uno

Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\Arduino\hardware -hardware C:\Users\PADL Palihawadana\Documents\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\PADL Palihawadana\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10807 -build-path C:\Users\PADLPA~1\AppData\Local\Temp\arduino_build_83264 -warnings=none -build-cache C:\Users\PADLPA~1\AppData\Local\Temp\arduino_cache_334753 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files\Arduino\hardware\tools\avr -verbose C:\Users\PADL Palihawadana\Documents\Arduino\hardware\libpololu-arduino\avr\libraries\Pololu3pi\examples\PID3piLineFollower\PID3piLineFollower.ino
C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files\Arduino\hardware -hardware C:\Users\PADL Palihawadana\Documents\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\PADL Palihawadana\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10807 -build-path C:\Users\PADLPA~1\AppData\Local\Temp\arduino_build_83264 -warnings=none -build-cache C:\Users\PADLPA~1\AppData\Local\Temp\arduino_cache_334753 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files\Arduino\hardware\tools\avr -verbose C:\Users\PADL Palihawadana\Documents\Arduino\hardware\libpololu-arduino\avr\libraries\Pololu3pi\examples\PID3piLineFollower\PID3piLineFollower.ino
Using board 'uno' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Build options changed, rebuilding all
Detecting libraries used...
"C:\\Program Files\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\PADLPA~1\\AppData\\Local\\Temp\\arduino_build_83264\\sketch\\PID3piLineFollower.ino.cpp" -o nul
PID3piLineFollower:14:23: error: Pololu3pi.h: No such file or directory

compilation terminated.

exit status 1
Pololu3pi.h: No such file or directory

Please advice

Thanks in advanced

Your Arduino IDE cannot find the Pololu3pi.h file. Looks like you had this issue before here. Please see my response.

- Amanda