Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to display this data to lcd ?

Status
Not open for further replies.

mishra12

Advanced Member level 2
Joined
Feb 18, 2009
Messages
672
Helped
136
Reputation
272
Reaction score
122
Trophy points
1,323
Location
some where left alone
Activity points
4,915
dear
i wan to display cmp03 compass value in lcd can any one suggest how to interface with lcd to show data ?/*


This will display a value of 0 - 359 for a full rotation of the compass.

The SDA line is on analog pin 4 of the arduino and is connected to pin 3 of the CMPS03.
The SCL line is on analog pin 5 of the arduino and is conected to pin 2 of the CMPS03.
Both SDA and SCL are also connected to the +5v via a couple of 1k8 resistors.
A switch to callibrate the CMPS03 can be connected between pin 6 of the CMPS03 and the ground.


*/
#include <Wire.h>

#define address 0x60 //defines address of compass

void setup(){
Wire.begin(); //conects I2C
Serial.begin(9600);
}

void loop(){
byte highByte;
byte lowByte;

Wire.beginTransmission(address); //starts communication with cmps03
Wire.send(2); //Sends the register we wish to read
Wire.endTransmission();

Wire.requestFrom(address, 2); //requests high byte
while(Wire.available() < 2); //while there is a byte to receive
highByte = Wire.receive(); //reads the byte as an integer
lowByte = Wire.receive();
int bearing = ((highByte<<8)+lowByte)/10;

Serial.println(bearing);
delay(100);
}
 

#include <Wire.h>
#include <LiquidCrystal.h>
#define address 0x60 //defines address of compass
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup(){
Wire.begin(); //conects I2C
lcd.begin(16, 2);
}

void loop(){
byte highByte;
byte lowByte;

Wire.beginTransmission(address); //starts communication with cmps03
Wire.send(2); //Sends the register we wish to read
Wire.endTransmission();

Wire.requestFrom(address, 2); //requests high byte
while(Wire.available() < 2); //while there is a byte to receive
highByte = Wire.receive(); //reads the byte as an integer
lowByte = Wire.receive();
int bearing = ((highByte<<8)+lowByte)/10;

lcd.print(bearing);
delay(100);
}
 

The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top