I want to now add an ds1307 rtc: http://compare.ebay.com/like/230584918558?var=lv<yp=AllFixedPriceItemTypes&var=sbar&rvr_id=211542956240&crlp=1_263602_309572&UA=%3F*F%3F&GUID=3b73156d12e0a0aa16e46b44ff7e7126&itemid=230584918558&ff4=263602_309572
How can I combine a code that runs the RTC with my other code below:
//zoomkat 12-22-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again
#include <SPI.h>
#include <Ethernet.h>
String readString, readString1;
int x=0;
char lf=10;
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x22, 0x8A };
byte ip[] = { 192, 168, 0, 104 };
byte server[] = { 97, 74, 166, 239 };
Client client(server, 80);
void setup()
{
byte gateway[] = { 192, 168, 0, 1 };
Ethernet.begin(mac, ip, gateway);
Serial.begin(9600);
Serial.println("starting simple arduino client test");
Serial.println();
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /processedfeed.aspx?feedcode=%5Bbc_u1%5Dhttp%253A//pipes.yahoo.com/pipes/pipe.run%253F_id%253D6d2c0b97b3c18eba6be661489a35c9c3%2526_render%253Drss%5B/bc_u1%5D%5Bbc_m1%5D3%5B/bc_m1%5D%5Bbc_o%5D0%5B/bc_o%5D HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
if (c==lf) x=(x+1);
if (x==14) readString += c;
readString += c;
}
if (!client.connected()) {
client.stop();
Serial.println("Current data row:" );
Serial.print(readString);
Serial.println();
readString1 = (readString.substring(41,43));
Serial.println();
Serial.print("DPD sec: ");
Serial.println(readString1);
Serial.println("done");
for(;;);
}
}
Here is the RTC Code:
/*
* TimeRTC.pde
* example code illustrating Time library with Real Time Clock.
*
*/
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup() {
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
}
void loop()
{
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
I got the RTC up and running. Now all I havve to do is combine the following RTC code with the code in the first post:
/*
* TimeRTC.pde
* example code illustrating Time library with Real Time Clock.
*
*/
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup() {
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
}
void loop()
{
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
Sure.
Put the stuff that goes before setup with the other stuff that is before setup.
Put the stuff that is in setup in with the setup stuff.
Put the void loop code (the little there is) in void loop.
Put the other functions after the void loop.
Check for duplicate use of pins, variable names Serial.begin at different speeds, etc.
Combined:5: error: expected constructor, destructor, or type conversion before '.' token
Combined:17: error: expected constructor, destructor, or type conversion before '.' token
Combined:18: error: expected constructor, destructor, or type conversion before '.' token
Combined:19: error: expected constructor, destructor, or type conversion before '.' token
Combined:20: error: expected constructor, destructor, or type conversion before '.' token
Combined:21: error: expected constructor, destructor, or type conversion before '.' token
Combined:22: error: expected constructor, destructor, or type conversion before '.' token
Combined:23: error: expected constructor, destructor, or type conversion before '.' token
Combined:24: error: expected constructor, destructor, or type conversion before '.' token
Combined:26: error: expected unqualified-id before 'for'
Combined:26: error: expected constructor, destructor, or type conversion before '<' token
Combined:26: error: expected constructor, destructor, or type conversion before '++' token
Combined:32: error: expected constructor, destructor, or type conversion before '.' token
Combined:33: error: expected constructor, destructor, or type conversion before '.' token
Combined:34: error: expected constructor, destructor, or type conversion before '.' token
Combined:35: error: expected constructor, destructor, or type conversion before '.' token
Combined:37: error: expected unqualified-id before 'if'
Combined:41: error: expected unqualified-id before 'else'
Combined:45: error: expected declaration before '}' token
That gives me this:
C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\UdpBytewise.cpp:30:19: error: types.h: No such file or directory
In file included from C:\Users\Christopher\Documents\arduino-0022\libraries\SPI/SPI.h:15,
from C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\utility/w5100.h:14,
from C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\UdpBytewise.cpp:31:
C:\Users\Christopher\Documents\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:18: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with
C:\Users\Christopher\Documents\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:17: error: previous declaration 'uint16_t makeWord(uint16_t)' here
C:\Users\Christopher\Documents\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:28: error: declaration of C function 'long int random(long int)' conflicts with
c:/users/christopher/documents/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here
C:\Users\Christopher\Documents\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:29: error: declaration of C function 'long int random(long int, long int)' conflicts with
C:\Users\Christopher\Documents\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:28: error: previous declaration 'long int random(long int)' here
C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\UdpBytewise.cpp: In member function 'void UdpBytewiseClass::begin(uint16_t)':
C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\UdpBytewise.cpp:46: error: 'Sn_MR_UDP' was not declared in this scope
C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\UdpBytewise.cpp: In member function 'int UdpBytewiseClass::available()':
C:\Users\Christopher\Documents\arduino-0022\libraries\Ethernet\UdpBytewise.cpp:55: error: 'getSn_RX_RSR' was not declared in this scope
That seems to have gotten worse then.
I can only compile a little because I don't have the libraries installed. This looke like missing library errors to me.