So, i got a clock code, the one as example in Time lib and i got a thermometer code written by myself. I was trying to fuse them and make a selector with a simple open-closed switch but i just kept getting errors that when i went to check them, there were no errors in that line. This is one of them
Arduino:1.8.1 (Windows 10), Tarjeta:"Arduino/Genuino Uno"
E:\Marcos\Documents\Arduino\In_progress\In_progress.ino: In function 'void setup()':
In_progress:24: error: 'requestSync' was not declared in this scope
setSyncProvider( requestSync); //set function to call when sync required
^
E:\Marcos\Documents\Arduino\In_progress\In_progress.ino: In function 'void loop()':
In_progress:105: error: 'processSyncMessage' was not declared in this scope
processSyncMessage();
^
In_progress:108: error: 'digitalClockDisplay' was not declared in this scope
digitalClockDisplay();
^
In_progress:117: error: 'FirsTime2' was not declared in this scope
if (FirsTime2 == 0) {
^
In_progress:132: error: a function-definition is not allowed here before '{' token
void digitalClockDisplay(){
^
In_progress:158: error: a function-definition is not allowed here before '{' token
void printDigits(int digits){
^
In_progress:167: error: a function-definition is not allowed here before '{' token
void processSyncMessage() {
^
In_progress:183: error: expected '}' at end of input
}
^
exit status 1
'requestSync' was not declared in this scope
Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.
Here is my code BTW
#include <LiquidCrystal.h>
int FirstTime1;
int FirstTime2;
int Lectura1;
int AnalogPin = A3;
float tempC;
int tempPin = 0;
float time1;
float time2;
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);
#include <TimeLib.h>
#define TIME_HEADER "T" // Header tag for serial time sync message
#define TIME_REQUEST 7 // ASCII bell character requests a time sync message
int estado = timeStatus();
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0,1);
Serial.begin(9600);
while (!Serial) ; // Needed for Leonardo only
pinMode(13, OUTPUT);
setSyncProvider( requestSync); //set function to call when sync required
while (50 >= time2) {
lcd.clear();
if (10 >= time2){
lcd.print("ArduinOS V 1.5");
lcd.setCursor(0,1);
lcd.print("[ ]");
delay(400);
lcd.clear();
time2 = time2 + 1;
}
if (20 >= time2 && time2 >= 10){
lcd.print("ArduinOS V 1.5");
lcd.setCursor(0,1);
lcd.print("[== ]");
delay(400);
lcd.clear();
time2 = time2 + 1;
}
if (30 >= time2 && time2 >= 20){
lcd.print("ArduinOS V 1.5");
lcd.setCursor(0,1);
lcd.print("[===== ]");
delay(400);
lcd.clear();
time2 = time2 + 1;
}
if (40 >= time2 && time2 >= 30){
lcd.print("ArduinOS V 1.5");
lcd.setCursor(0,1);
lcd.print("[======== ]");
delay(400);
lcd.clear();
time2 = time2 + 1;
}
if (50 >= time2 && time2 >= 40){
lcd.print("ArduinOS V 1.5");
lcd.setCursor(0,1);
lcd.print("[==========]");
delay(400);
lcd.clear();
time2 = time2 + 1;
}
}
}
void lectura() {
lcd.clear();
tempC = analogRead(tempPin);
tempC = (5.0 * tempC * 100.0)/1024.0;
time1 = 0;
lcd.print(tempC);
lcd.print(" C");
lcd.setCursor(0,1);
if (tempC >= 25) {
lcd.print("Hace calor");
}
if (20 >= tempC) {
lcd.print("Hace frio");
}
if (25 >= tempC && tempC >= 20) {
lcd.print("Esta agradable");
}
}
void loop(){
Lectura1 = analogRead(AnalogPin);
if (Lectura1 == 0){
lcd.clear();
if (FirstTime1 == 0) {
lcd.print("Loading");
lcd.setCursor(0,1);
lcd.print("Clock");
FirstTime1 == FirstTime1 + 1;
delay(1000);
}
if (timeStatus() == timeNotSet) {
lcd.clear();
lcd.print("Waiting for");
lcd.setCursor(0,1);
lcd.print("Synchronasation");
}
if (Serial.available()) {
processSyncMessage();
}
if (timeStatus()!= timeNotSet) {
digitalClockDisplay();
}
if (timeStatus() == timeSet) {
} else {
}
delay(1000);
}
if (Lectura1 != 0) {
lcd.clear();
if (FirsTime2 == 0) {
lcd.print("Loading");
lcd.setCursor(0,1);
lcd.print("Thermometer");
delay(1000);
FirstTime2 == FirstTime2 + 1;
}
time1= time1 + 1;
if (time1 == 100) {
lectura();
}
}
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();
lcd.setCursor(0,0);
lcd.print(hour());
lcd.print(":");
lcd.print(minute());
lcd.print(":");
lcd.print(second());
lcd.setCursor(0,1);
lcd.print(day());
lcd.print("/");
lcd.print(month());
lcd.print("/");
lcd.print(year());
}
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);
}
void processSyncMessage() {
unsigned long pctime;
const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
if(Serial.find(TIME_HEADER)) {
pctime = Serial.parseInt();
if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013)
setTime(pctime); // Sync Arduino clock to the time received on the serial port
}
}
}
time_t requestSync()
{
Serial.write(TIME_REQUEST);
return 0; // the time will be sent later in response to serial mesg
}