Data Sheet
Example Code
The sketch below gives you an idea of the minimal code required to talk to tinyLiDAR from an Arduino
UNO. Compiled size is only 2396 bytes!
• Note that although this sketch can provide data at up to 75Hz using the default single step
mode, new data is available at “only” up to approx a 60Hz scan rate. If desired, even faster
reading rates of up to approx 930Hz are possible - see Appendix A for details.
void setup()
{
Serial.begin(115200); //setup the serial port
I2c.begin();
}
void loop()
{
uint16_t i;
while(1)
{
I2c.write(0x10,'D'); //take single measurement
I2c.read(0x10,2); // request 2 bytes from tinyLiDAR
i = I2c.receive(); // receive MSB byte
i = i<<8 | I2c.receive(); // receive LSB byte and put them together
Serial.println(i); // print distance in mm
delay(100); // delay as required (30ms or higher in default single step mode)
}
}
Serial (TTY) Log Output
As an option, you can monitor some of the activity from tinyLiDAR on its serial log output port.
This output only serial stream is available from pin 1 as shown in the diagram below.
Serial parameters as used on TeraTerm are: 115200 baud, 7data bits, no parity, 1 stop bit, and no flow control.
Sample output is shown below:
tinyLiDAR Reference Manual rev1.26 6