Any Idea how to display the reading taken by an HC-SR04 ultrasonic module on a 4 digit seven segment module(TM1637)
I'm using the "TM1637Display.h" library from GitHub and so far successfully tried the example that came along with it.
I use a Arduino nano clone with CH340G.
I'm a total noob. I just want the distance data retrieved by the ultrasonic module to show on the TM1637 module just like it shows up in the serial monitor.
I don't have the library or the example code but if you post the example code for the display we can work out whats being displayed. Once you know whats being displayed its just a simple case of moving the distance from the untrasonic into that spot.
also there is this PDF called "User guide for TM1637 4 digits display - Arduino Forum"
i don't know the link, but you get it as the first result if you search google using exact words.
Any Idea how to display the reading taken by an HC-SR04 ultrasonic module on a 4 digit seven segment module(TM1637)
Sure - you hook the module and the display up to an arduino and write a sketch to read your device and output to your display.
What's the problem?
Can you not get the numbers off the module? Do you know how the module talks? Using i2c/wire? Hook it to a analog in? Talk to it over serial?
Do you not know know how to convert the reading it gives you into four decimal digits?
Do you not know how to write a four-digit number of your choice to your display?
Is it the overall structure that's bugging you? How about this?
variables to store the reading go here;
void loop() {
take_reading();
display_reading();
sleep(1000);
}
void take_reading() {
fill in the blank;
}
void display_reading() {
fill in the blank;
}
Basically, "I haz hardware, how do I write codes?" isn't really specific enough. As to how you go about writing the code, break the job into tasks - reading the sensor and writing to the display, and get those working.
Thanks for the info, in fact as per your suggestion, 153 is the number displayed.
gpop1:
with out getting the library it looks like numbers are displayed using
display.showNumberDec(153, false, 3, 1);
you should play with this section of code or read up to find out what it does
if 153 is the number displayed then just move your reading into this spot
I somehow managed to move my reading into that spot like this.
int x = (sonar.ping_cm()); display.showNumberDec(x,false,3,1);
and guess what, it works...yay.
But now a new problem has arisen, the number shown in the display module is different from what is shown in the serial monitor.
my problem was that i did not know how to get the readings shown in the serial monitor to display on my seven segment module.
now that its somehow solved, a new problem haz arizen. incorrect numbers on display. please help me out.
You take two readings every five seconds.
It's right there in your code.
Take one reading right after the delay, assign the value to x, and only print the value of x
The other advantage of doing only one reading is that you don't do two back-to back pings and run the risk that the second gets a distant echo from the first ping, and possibly misinterpreting it as being an object closer than is actually the case.
(This library may prevent such an occurrence - I don't know, I've never used it)