pessoal, podem por favor me ajudar com este exemplo do cook book.

já adicionei a library time e consigo mostrar num LCD ou monitor serial a hora e data, mas tentando tornar o relogio ajustavel da sempre este erro.

sketch_mar23c.cpp: In function 'void loop()':
sketch_mar23c:19: error: 'digitalClockDisplay' was not declared in this scope
sketch_mar23c.cpp: In function 'boolean checkSetTime()':
sketch_mar23c:37: error: 'digitalClockDisplay' was not declared in this scope


 o codigo esta exatamente como no cook book


#include <Time.h>
const int potPin = 0; // pot to determine direction and speed
const int buttonPin = 2; // button enables time adjustment
unsigned long prevtime; // when the clock was last displayed
void setup()
{
digitalWrite(buttonPin, HIGH); // enable internal pull-up resistors
setTime(12,0,0,1,1,11); // start with the time set to noon Jan 1 2011
Serial.begin(9600);
}
void loop()
{
prevtime = now(); // note the time
while( prevtime == now() ) // stay in this loop till the second changes
{
// check if the set button pressed while waiting for second to roll over
if(checkSetTime())
prevtime = now(); // time changed so reset start time
}
digitalClockDisplay();
}
// functions checks to see if the time should be adjusted
// returns true if time was changed
boolean checkSetTime()
{
int value; // a value read from the pot
int step; // the number of seconds to move (backwards if negative)
boolean isTimeAdjusted = false; // set to true if the time is adjusted
while(digitalRead(buttonPin)== LOW)
{
// here while button is pressed
value = analogRead(potPin); // read the pot value
step = map(value, 0,1023, 10, -10); // map value to the desired range
if( step != 0)
{
adjustTime(step);
isTimeAdjusted = true; // to tell the user that the time has changed
digitalClockDisplay(); // update clock
delay(100);
}
}
return isTimeAdjusted;
}


tambem já tentei usar a library DateTime mas não da resultados, só outros erros.

conto com a ajuda dos feras do Lab de garagem.

vlw.

Exibições: 265

Responder esta

Respostas a este tópico

Erick,

Esse erro pode estar acontecendo porque o compilador não está reconhecendo a digitalClockDisplay() como uma função declarada. No cookbook o autor mandar incluir apenas a biblioteca Time.h? Ele não pede para incluir nenhuma outra. Se não, a função digitalClockDisplay() deveria estar lá dentro. Sugiro que você abra a biblioteca Time.h e procure essa função digitalClockDisplay() por lá. Se você não achar, esse é o erro. Então precisa ver qual é a declaração correta que a biblioteca faz para a função e desempenha o mesmo papel no programa (printar a hora).

Boa sorte! 

fala marcelo, esse problema só acontece quando tento fazer com que o relogio fique ajustavel, já estou usando essa função e não tenho notado problema algum, mas de qualquer formar vou abrir a library e dar uma olhada.

vlw.

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço