Pages: [1]   Go Down
Author Topic: LCD/serial monitor  (Read 1067 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone,

I am currently using a hall sensor to detect a magnet, and I was wondering if it was possible to have the live results from my serial monitor be on my LCD instead....if not, then could anyone provide any info to get my lcd to display what the hall sensor is sensing?
Logged

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

Post your code so we can point to the places you can insert your lcd print functions.
Logged


Offline Offline
Full Member
***
Karma: 0
Posts: 200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This can be VERY easy. 
If you have plenty of pins free and not much cash, hit sparkfun.com or adafruit.com and find an LCD display.  Probably $17 shipped. 

If you have more cash, this unit is dead easy and will likely work without changing a line of code:
http://www.sparkfun.com/products/10097 ($25)

 I plugged in the second one to a little project I had and was going to go read the manual then realized it was displaying all my EXISTING serial.println calls without any changes.   I often START with that unit on new projects then go back and put in a basic LCD - easy, just more wiring involved, then deploy.
Logged

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

You can buy 3-4 such LCDs if you buy from this place: smiley-cool

http://dipmicro.com/store/LCD-1602A-Y
Logged


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

Already got the LCD...went with the arduino hd44780....but here is the code for my sensor:

int sensorPin = A0;    // select the input pin for the sensor
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
 Serial.println(sensorValue); 
 delay (75);
 
}
Logged

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

Already got the LCD...went with the arduino hd44780....but here is the code for my sensor:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 7, 6, 2, 4); //Phi-1 shield setting

int sensorPin = A0;    // select the input pin for the sensor
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
 Serial.println(sensorValue);
  lcd.setCursor(0,0);
 lcd.print(sensorValue);
 lcd.print("   "); 
delay (75);
 
}

The line with LiquidCrystal lcd(8, 9, 7, 6, 2, 4); is for my Phi-1 shield. You may be told to use different pins from different online tutorials. The five numbers represent arduino pins to LCD pins R/S EN, D4 D5 D6 and D7.
Logged


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

Thanks for the help!  Im still experimenting with different codes for my hall sensor, and I like this one that I found on the arduino website:


/*
 *    FILE: MM01
 *  AUTHOR: Rob van den Tillaart
 *    DATE: 2010 03 19
 *
 * PURPOSE: use a A1301 as magnetometer   
 *
 * Pinlayout A1301
 * ==================
 *  1     GND
 *  2     signal    connected to Analog 0   
 *  3     Vdd +5V
 *
 */

int  time = 0;
int  oldtime = -1;
int  rawMM = 0;

#define BNULL 505L    // My midpoint, calibrate this
#define BFAC  1000L   // 2500 mv == 1000 Gauss in 505 steps

void setup()
{
  // setup serial - diagnostics - port
  Serial.begin(9600);
}

void DoMeasurement()
{
  // measure magnetics
  rawMM = analogRead(0);   // Range : 0..1024

  Serial.print("MM: ");
  Serial.print(rawMM);

  long B = rawMM - BNULL;  // adjust midpoint
  B = B * BFAC / BNULL;    // adjust scale -> -1000 .. +1000 Gauss

  Serial.print("  = B in Gauss: ");
  Serial.print(B);

  if (B > 0) Serial.println(" South-pole");
  else if (B <0) Serial.println(" North-pole");
  else Serial.println();
}

void loop()
{
  time = millis()/75;
  if (time == oldtime)
  {
    delay(100);
  }
  else
  {
    oldtime = time;
    DoMeasurement();
  }
}
  How would I put this into an LCD?
Logged

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

I just gave you the code. Read my reply. Add a few lines in your code to initialize the display, replace Serial.print with lcd.print. The rest is learning. You need to do it yourself. I can't help you with that.

Logged


Pages: [1]   Go Up
Jump to: