Poll
Question: 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 ^^ - 2 (50%)
and briefly what does this coding mean "val = map(val, 0, 1023, 0, 225);" please kindly help ^^ - 2 (50%)
Total Voters: 4

Pages: [1]   Go Down
Author Topic: Sensor Hall effect display in LCD  (Read 1919 times)
0 Members and 1 Guest are viewing this topic.
Malaysia
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Malaysia
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okey, tq robtilaart^^
Any suggestion on LCD display? I have trouble to use input from sensor to be display..  smiley-roll-sweat
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okey, tq robtilaart^^
Any suggestion on LCD display? I have trouble to use input from sensor to be display..  smiley-roll-sweat

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 Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought "Jokes" were inappropriate here...

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4258
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are a few pointers.
You want this part in setup because it doesn't ever change.

Code:
lcd.print("the rpm now is....");

You want this part in loop because it does change
Code:
 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 Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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? smiley-sweat smiley-sweat
Logged

Malaysia
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ola pessoal preciso fazer o programa abaixo sesnor de efeito hall para jogar no display 1602

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int hallPin=13;
int statePin=LOW;

void setup()
{
   lcd.begin(16, 2);
  lcd.print("ROTACAO");
pinMode(hallPin,INPUT);
Serial.begin(9600);
}
void loop()
{
statePin=digitalRead(hallPin);
if (Serial.available())
{
if( statePin==HIGH)
{
Serial.println("North");
}
else if(statePin==LOW)
{
Serial.println("South");
lcd.setCursor(1, 1);
}
}
delay(500);
}
Logged

Pages: [1]   Go Up
Jump to: