Need Help on LCD And RTC
Need Help on LCD And RTC
Hi katchupoy,
Need your help to continue my work
My stuff not yet complete i try to write a code for LCD & RTC that is the stuff i got now.
so i need try for upload ur code for my LCD and RTC. I use this code and delete some code;
/*
originally written by Christian,
cptbjorn@gmail.com
modified by Cesar,
caddnima@gmail.com,
https://sites.google.com/site/caddnima/
Version 1.00, 2012-03-13
*/
#define DS1307_I2C_ADDRESS 0x68 // address used for clock
#include "Wire.h" // library used
#include <LiquidCrystal.h> // library used
/* ********************************************************************************* */
/* * * */
/* * originally arduino pins 8, 9, 4, 5, 6, 7 are used, * */
/* * I have to use different arduino non pwm pins, so I can reserved the pwm * */
/* * pins for other use.(RS, EN , D4, D5, D6, D7 * */
/* * * */
/* ********************************************************************************* */
LiquidCrystal lcd(13, 12, 7, 6, 5, 4);
/* ******************************************************************************************************************** */
/* * * */
/* * R T C C L O C K D S 1 3 0 7 * */
/* * * */
/* ******************************************************************************************************************** */
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
return ( (val/16*10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour)); // If you want 12 hour am/pm you need to set
// bit 6 (also need to change readDateDs1307)
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.writ(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
/* ******************************************************************************************************************** */
/* * * */
/* * D E F I N E : O N E S E C O N D * */
/* * * */
/* ******************************************************************************************************************** */
void onesecond() //function that runs once per second while program is running
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
lcd.setCursor(0, 0);
if(hour>0)
{
if(hour<=12)
{
lcd.print(hour, DEC);
}
else
{
lcd.print(hour-12, DEC);
}
}
else
{
lcd.print("12");
}
lcd.print(":");
if (minute < 10) {
lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if (second < 10) {
lcd.print("0");
}
lcd.print(second, DEC);
if(hour<12)
{
lcd.print("am");
}
else
{
lcd.print("pm");
}
lcd.print(" ");
delay(1000);
}
/* ******************************************************************************************************************** */
/* * * */
/* * S E T U P - D I S P L A Y * */
/* * * */
/* ******************************************************************************************************************** */
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
second = 56;
minute = 57;
hour = 23;
dayOfWeek = 6; // Sunday is 0
dayOfMonth = 26;
month = 2;
year = 11;
/* ********************************************************************************* */
/* * * */
/* * this is where you set your time... * */
/* * 1) change the second, minute, hour, etc above * */
/* * 2) remove // below * */
/* * 3) and load this sketch to your arduino * */
/* * 4) after loading the sketch, put the // back again * */
/* * 5) and load this sketch again to your arduino, and save * */
/* * * */
/* ********************************************************************************* */
//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
lcd.begin(16, 2); // set up the LCD's number of rows and columns:
// lcd.print("12:00 80.6"); // Print a message to the LCD.
// lcd.print(char(223));
lcd.setCursor(0, 1);
lcd.print("blue:");
lcd.setCursor(8, 1);
lcd.print("white:");
}
But i can't compile and upload the code, it said error like this;
sketch_jul02a.cpp: In function 'void setDateDs1307(byte, byte, byte, byte, byte, byte, byte)':
sketch_jul02a:73: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:74: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:75: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:76: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:78: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:79: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:80: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a:81: error: 'class TwoWire' has no member named 'send'
As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.
sketch_jul02a.cpp: In function 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)':
sketch_jul02a:96: error: 'class TwoWire' has no member named 'writ'
sketch_jul02a:102: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a:103: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a:104: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a:105: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a:106: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a:107: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a:108: error: 'class TwoWire' has no member named 'receive'
As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.
sketch_jul02a.cpp: At global scope:
sketch_jul02a:170: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:171: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:172: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:173: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:174: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:175: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:176: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:177: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:193: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:196: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:197: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:198: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:199: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:200: error: expected declaration before '}' token
Can somebody help me? and am i missing somthing?
thanks