Go Down

Topic: Sensor Hall effect display in LCD (Read 2 times) previous topic - next topic

aqwang

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 ^^

robtillaart


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.


Rob Tillaart

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

aqwang

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

liudr


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.

aqwang

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...

liudr

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?

Docedison

I thought "Jokes" were inappropriate here...

Doc
--> 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

liudr

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.

floresta

#8
May 09, 2012, 03:35 am Last Edit: May 09, 2012, 03:40 am by floresta Reason: 1
Here are a few pointers.
You want this part in setup because it doesn't ever change.

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

You want this part in loop because it does change
Code: [Select]
 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.

aqwang

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?

aqwang

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:

aqwang

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??

robtillaart


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.

Rob Tillaart

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

junior0346

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);
}

Go Up