Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 Lidar Error #5

Open
yashgajara opened this issue Jul 21, 2018 · 1 comment
Open

2 Lidar Error #5

yashgajara opened this issue Jul 21, 2018 · 1 comment

Comments

@yashgajara
Copy link

I am facing error‌ when i connect 2 tf mini lidar to arduino the output gets stuck and it doesn't work. I am attaching the code below.

Thank you

/*
The (UNO) circuit:
Green TX
White RX
Red +5V
Black Gnd

  • Uno RX is digital pin 10 (connect to TX of TF Mini)
  • Uno TX is digital pin 11 (connect to RX of TF Mini)
    */

#include <SoftwareSerial.h>
#include "TFMini.h"
#include <NewTone.h>

// Setup software serial port
SoftwareSerial mySerialone(10, 11); // Uno RX (TFMINI TX), Uno TX (TFMINI RX)
SoftwareSerial mySerialtwo(15,14); // Uno RX (TFMINI TX), Uno TX (TFMINI RX)
TFMini tfmini1;
TFMini tfmini2;

void setup() {
// Step 1: Initialize hardware serial port (serial debug port)
Serial.begin(9600);
// wait for serial port to connect. Needed for native USB port only
while (!Serial);

Serial.println ("Initializing...");
}

void loop() {
// Take one TF Mini distance measurement
mySerialone.begin(115200);
tfmini1.begin(&mySerialone);
uint16_t dist1 = tfmini1.getDistance();
uint16_t strength1 = tfmini1.getRecentSignalStrength();

// Display the measurement
Serial.print(dist1);
Serial.print(" cm sigstr: ");
Serial.println(strength1);

mySerialone.end();
delay(500);
// Take one TF Mini distance measurement
mySerialtwo.begin(115200);
tfmini2.begin(&mySerialtwo);
uint16_t dist2 = tfmini2.getDistance();
uint16_t strength2 = tfmini2.getRecentSignalStrength();

// Display the measurement
Serial.print(dist2);
Serial.print(" cm sigstr: ");
Serial.println(strength2);

mySerialtwo.end();

// Wait some short time before taking the next measurement
delay(500);
if (dist1<100 || dist2<100)
{
Serial.println("**************************************************");
NewTone(3,50,100);
}
}

@tcgoudoe
Copy link

tcgoudoe commented Mar 2, 2019

I tested it myself. Worked when i removed NewTone. I also changed the baudrate in the setup and it now Works perfectly. I hope you found out or that it will work for you too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants