Created
February 9, 2016 01:46
-
-
Save vasmani/3e9c8be027c99ec9cb4e to your computer and use it in GitHub Desktop.
tm1637 + sr04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <NewPing.h> | |
| #include <TM1637Display.h> | |
| const int CLK = 2; //Set the CLK pin connection to the display | |
| const int DIO = 3; //Set the DIO pin connection to the display | |
| #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor. | |
| #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor. | |
| #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. | |
| TM1637Display display(CLK, DIO); //set up the 4-Digit Display. | |
| NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. | |
| void setup() { | |
| display.setBrightness(0x0a); //set the diplay to maximum brightness | |
| } | |
| void loop() { | |
| display.showNumberDec(sonar.ping_cm()); //Display the Variable value; | |
| delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings. | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment