Skip to content

Commit

Permalink
Added PWM example and updated PWM diagram to include the 680uF capacitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Meyers committed Aug 11, 2015
1 parent 30ae4c9 commit 5302c7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Binary file modified Diagrams/ArduinoPWMWiring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Diagrams/PinoutPWMWiring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions LIDARLite/examples/Single Sensor/PWM/PWM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
This example demonstrates how to read measurements from LIDAR-Lite v2 "Blue
Label" using PWM
The library is in BETA, so subscribe to the github repo to recieve updates, or
just check in periodically:
https://github.com/PulsedLight3D/LIDARLite_v2_Arduino_Library
To learn more read over lidarlite.cpp as each function is commented
=========================================================================== */

void setup() {
// put your setup code here, to run once:
unsigned long pulse_width;

void setup()
{
Serial.begin(115200); // Start serial communications
pinMode(2, OUTPUT); // Set pin 2 as trigger pin
pinMode(3, INPUT); // Set pin 3 as monitor pin
digitalWrite(2, LOW); // Set trigger LOW for continuous read
}

void loop() {
// put your main code here, to run repeatedly:

void loop()
{
pulse_width = pulseIn(3, HIGH); // Count how long the pulse is high in microseconds
if(pulse_width != 0){ // If we get a reading that isn't zero, let's print it
pulse_width = pulse_width/10; // 10usec = 1 cm of distance for LIDAR-Lite
Serial.println(pulse_width); // Print the distance
}
}

0 comments on commit 5302c7e

Please sign in to comment.