Malaysia
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« on: May 05, 2012, 01:06:26 pm » |
I'm newbie with arduino Uno, I used LCD 16x2, what is the simple way of coding the output from sensor to be display by LCD? and briefly what does this coding mean "val = map(val, 0, 1023, 0, 225);" please kindly help ^^
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9421
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #1 on: May 05, 2012, 01:32:05 pm » |
val = map(val, 0, 1023, 0, 225);
this line of code means : do a linear interpolation of the value of val with range( 0..1023) to a range (0..225)
examples if val == 0 it will map upon 0 if val == 1023 it will map upon 225 if val == 512 it will map upon 112 if val == 256 it wil map upon 56 if val == 768 it will map upon 168
etc.
|
|
|
|
|
Logged
|
|
|
|
|
Malaysia
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #2 on: May 05, 2012, 07:43:13 pm » |
Okey, tq robtilaart^^ Any suggestion on LCD display? I have trouble to use input from sensor to be display.. 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5938
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #3 on: May 05, 2012, 09:36:32 pm » |
Okey, tq robtilaart^^ Any suggestion on LCD display? I have trouble to use input from sensor to be display..  OK, did your LCD work with example code? The word "trouble" is just 7 characters. It doesn't say much about what you are doing, what works and what doesn't work, not to mention you don't provide code either. Do better next time you ask a question.
|
|
|
|
|
Logged
|
|
|
|
|
Malaysia
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #4 on: May 05, 2012, 10:34:12 pm » |
Sorry my question is not clear.. this is example coding of my hall effect sensor, I'm using Arduino UNO.. sensor input is attach to pin 7 #include <LiquidCrystal.h> lcd.begin(16,2); lcd.setCursor(0,0); lcd.print("the rpm now is...."); lcd.printIn(rpm, DEC); So, the question is how i want to display the value from my pin 7 to the LCD? or it already...
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5938
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #5 on: May 06, 2012, 12:55:35 am » |
OK. I feel better about this already. What is the hall sensor supposed to do? Does it sense some speed or does it tell jokes to you? Don't make me guess. I don't guess well. Is there some other language you can use other than English?
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2311
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #6 on: May 08, 2012, 07:39:43 pm » |
I thought "Jokes" were inappropriate here...
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5938
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #7 on: May 08, 2012, 07:58:23 pm » |
I know I know. How about using analogy such as the OP feels like a hardened old tube of tooth paste? You squeeze so hard and only get so little each time. That was pretty much what I got. Ridiculously little information. There is no back ground story of what OP was trying to do, virtually no description of what exact hardware was used and what the actual goal was. If the OP has language barrier, there is a thing called google translate. It does a good job.
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Online
Faraday Member
Karma: 17
Posts: 3462
|
 |
« Reply #8 on: May 08, 2012, 08:35:13 pm » |
Here are a few pointers. You want this part in setup because it doesn't ever change.lcd.print("the rpm now is...."); You want this part in loop because it does change lcd.printIn(rpm, DEC); BUT - you don't want to use lcd.println() because it does not do what you expect it to, which is why it is not listed in the LiquidCrystal library documentation. AND- you will have to do some cursor positioning to get the updated values to overwrite the older values.Don [Edit]: When you put his code in a code box you see that he used lcd.printIn, not lcd.println. That's not in the LiquidCrystal library either.
|
|
|
|
« Last Edit: May 08, 2012, 08:40:46 pm by floresta »
|
Logged
|
|
|
|
|
Malaysia
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #9 on: May 10, 2012, 07:48:45 pm » |
floresta.. so i see, the data cannot overwrite with the past data right? does you mean the addition of cursor will help updated the rpm? and my motor already work, just that it can not display lcd.print..is it because serial.print cannot use together with lcd.print?
|
|
|
|
|
Logged
|
|
|
|
|
Malaysia
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #10 on: May 24, 2012, 11:27:22 pm » |
i have last question. rpm = 30*1000/(millis() - timeold)*rpmcount;> what does this define? why 30 multiply by 1000 in this code? one revolution is 2 pai right? 
|
|
|
|
|
Logged
|
|
|
|
|
Malaysia
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #11 on: May 26, 2012, 12:24:54 pm » |
anyone can describe this formula plzz if (rpmcount >= 20) { //Update RPM every 20 counts, increase this for better RPM resolution, //decrease for faster update rpm = 30*1000/(millis() - timeold)*rpmcount; timeold = millis(); rpmcount = 0; Serial.println(rpm,DEC);} -the question is, Do we need to multiply 30 in the formula??
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9421
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #12 on: May 27, 2012, 09:00:29 am » |
wild guess mode
30 has to do with calculating the rounds per minute. 30* 1000 sounds like halve a minute so somewhere a factor 2 was smuggled in (2 magnets, 2 pulses per RPM, 2 sensors or so)
Please post the whole code and schematics, the more info you give the better answers we can provide.
|
|
|
|
|
Logged
|
|
|
|
|
|