Function that change frequency of tfmini-s

Hi
I want code to change the frame rate(frequency) of laser sensor tfmini-s to be
more than 100
For Arduino uno

Is this a commercial order? Are you ready to pay for code?

3 Likes

Why don't you just go ahead and do it?

1 Like

No i only want to know the function that can change the value of Frame rate

I already have code that operate tfmini-s
But i only want to know the function that can change the value of Frame rate

Every now and then it is extremely useful to have a look at the libary used for this purpose.

Are you using any library to work with tfmini-s ?

Yes i use library
TFMini.h
And
I used function
(SetCommand(SET_FRAME_RATE,FRAME_300
But it didn't work

I use library
TFMini.h
So i just want to know the function that change frequency
I used function
SetCommand(SET_FRAME_RATE,FRAME_300)
and it didn't defined IN that library

Where did you get this command from? There is no such command in the library.

This library doesn't contain a function to change the frame rate. If you need it - you should write it yourself. The command syntax can be found in the Manual:

This is the code

include <SoftwareSerial.h>
#include "TFMini.h"
TFMini tfmini;
 
SoftwareSerial SerialTFMini(2, 3);          //The only value that matters here is the first one, 2, Rx
 
void getTFminiData(int* distance, int* strength)
{
  static char i = 0;
  char j = 0;
  int checksum = 0;
  static int rx[9];
  if (SerialTFMini.available())
  {
    rx[i] = SerialTFMini.read();
    if (rx[0] != 0x59)
    {
      i = 0;
    }
    else if (i == 1 && rx[1] != 0x59)
    {
      i = 0;
    }
    else if (i == 8)
    {
      for (j = 0; j < 8; j++)
      {
        checksum += rx[j];
      }
      if (rx[8] == (checksum % 256))
      {
        *distance = rx[2] + rx[3] * 256;
        *strength = rx[4] + rx[5] * 256;
      }
      i = 0;
    }
    else
    {
      i++;
    }
  }
}
 
 
void setup()
{
  Serial.begin(115200);       //Initialize hardware serial port (serial debug port)
  while (!Serial);            // wait for serial port to connect. Needed for native USB port only
  Serial.println ("Initializing...");
  SerialTFMini.begin(TFMINI_BAUDRATE);    //Initialize the data rate for the SoftwareSerial port
  tfmini.begin(&SerialTFMini);            //Initialize the TF Mini sensor
}
 
void loop()
{
  int distance = 0;
  int strength = 0;
 
  getTFminiData(&distance, &strength);
  while (!distance)
  {
    getTFminiData(&distance, &strength);
    if (distance)
    {
      Serial.print(distance);
      Serial.print("cm\t");
      Serial.print("strength: ");
      Serial.println(strength);
    }
  }
  delay(100);
}

Can u give me hint to how can i write this function cause the manual use hexadecimal statements and i don't understand it

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.