Skip to content

Instantly share code, notes, and snippets.

@sfambach
Created May 2, 2020 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfambach/be2c5f4fcae3fec26aafa275027dc207 to your computer and use it in GitHub Desktop.
Save sfambach/be2c5f4fcae3fec26aafa275027dc207 to your computer and use it in GitHub Desktop.
/**
* Example from the library.
* I changed the two hardware serials to one software serial
* More details under http://www.fambach.net/FTMini-Laser/
*
* The original lib to be no longer existing in Git, install it via Arduino Gui (keyword = tfmini, Author= hideakitai)
*
*/
#include "TFmini.h"
#include <SoftwareSerial.h>
/**
* Prepare the sensor
*/
SoftwareSerial mySerial(10, 11);
TFmini tfmini;
void setup()
{
Serial.begin(115200);
// init the sensor
mySerial.begin(TFmini::DEFAULT_BAUDRATE);
tfmini.attach(mySerial);
}
void loop()
{
// get some data from the sensor
if (tfmini.available())
{
Serial.print("tfmini ");
Serial.println(1);
Serial.print("distance : ");
Serial.println(tfmini.getDistance());
Serial.print("strength : ");
Serial.println(tfmini.getStrength());
Serial.print("int time : ");
Serial.println(tfmini.getIntegrationTime());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment