Hi, everyone!
(I'm completely newbie, so excuse me if my questions are stupid)
I made my first "device" (pic related). It works fine for a short period of time (like an hour or something like that), but then it goes crazy: led start blinking all the time and device don't respond when I change temperature.
Could you please tell me, what's wrong?
(I tried both - CR3024 battery and 3.3V power supply)
#include <msp430.h>
#include <RTCplus.h>
RealTimeClock rtc; //initialise the global RealTimeClock instance
int sensorPin = A3; // select the input pin for the potentiometer
int ledPin = P1_1; // select the pin for the LED
int sensorValue = 0;
#ifdef RTCWITHDATE
const char Months[]="JanFebMarAprMayJunJulAugSepOctNovDec";
#endif
void DisplayTime() //routine to format & print the time to the serial port
{
#ifdef RTCWITHDATE
const char * MonthText;
#endif
if (rtc.RTC_hr<10) Serial.write('0');
Serial.print(rtc.RTC_hr);
Serial.write(':');
if (rtc.RTC_min<10) Serial.write('0');
Serial.print(rtc.RTC_min);
Serial.write(':');
if (rtc.RTC_sec<10) Serial.write('0');
Serial.print(rtc.RTC_sec);
#ifdef RTCWITHDATE
MonthText=Months+(rtc.RTC_month-1)*3;
Serial.write(32);
if (rtc.RTC_day<10) Serial.write(32);
Serial.print(rtc.RTC_day);
Serial.write(32);
Serial.write(*(MonthText));
Serial.write(*(MonthText+1));
Serial.write(*(MonthText+2));
Serial.write(32);
Serial.print(rtc.RTC_year);
#endif
Serial.println(" ");
}
void setup()
{
Serial.begin(9600); //initialise Serial
pinMode(ledPin, OUTPUT);
rtc.begin(); //initialise the RTC
rtc.Set_Time(23,59,0); //Set the time to 23:56
#ifdef RTCWITHDATE
rtc.Set_Date(2013,2,28); //Set the date to 28 Feb 2013
#endif
};
void loop()
{
DisplayTime(); //call our routine that outputs the time
digitalWrite(ledPin, LOW);
if (rtc.RTC_min < 5) {
// CRYSTAL TEST
//digitalWrite(ledPin, HIGH);
//delay(25);
//digitalWrite(ledPin, LOW);
//delay(1975);
} else {
// THERMISTOR TEST
sensorValue=analogRead(sensorPin);
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(25);
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(sensorValue);
};
};
RTC_ISR(void) {
rtc.Inc(); // Update chunks
};
(The overall purpose of this device is just to log temperature on SD card)