O have this Sketch
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
int ledpin = 13;
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup()
{
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
while (!Serial) ; // wait until Arduino Serial Monitor opens
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()
{
// print the string when a newline arrives and turn led on/off
if (stringComplete)
{
Serial.println(inputString);
if(inputString == "1")
{
Serial.print(inputString);
if (timeStatus() == timeSet)
{
digitalClockDisplay();
}
else
{
Serial.println("The time has not been set. Please run the Time");
Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
Serial.println();
delay(4000);
}
delay(1000);
}
else if(inputString == "two")
{
digitalWrite(ledpin,LOW);
}
inputString = "";
stringComplete = false;
}
}
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);
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent()
{
while (Serial.available())
{
// get the new byte:
char inChar = (char)Serial.read();
// Serial.print(inChar); // add it to the inputString:
if (inChar == '\n')
{
stringComplete = true;
}
else
{
inputString += inChar;
}
}
}
It compiles without error on my win7-64 bit pc, but fail when I attempt to compile on my Raspberry Pi. The error is
/usr/share/arduino/libraries/Time/DateStrings.cpp:41:22: error: variable ‘monthNames_P’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/Time/DateStrings.cpp:58:20: error: variable ‘dayNames_P’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
/usr/share/arduino/libraries/Time/DateStrings.cpp:59:24: error: variable ‘dayShortNames_P’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
Any ideas?
Jim