I got a code and try to developed by ai a code of 16 digit 7 SEGMENTS common anode clock when I run in proteous Arduino uno in 4mhz it's work like charm but in physically it stuck and all segments showing 88:88:88. can any one help to recover and reconstruct the sketch? though I'm know nothing about programming
#include "RTClib.h"
RTC_DS3231 rtc;
// Global display array (16 digits) used for normal and setting modes.
int my_str[16];
int tempC, d;
// Button pins (using internal pull-ups)
const int upPin = 7;
const int downPin = 8;
const int okPin = 9;
const int savePin = 10;
// Shift register pins for 7-seg patterns
int latchPin = 12;
int clockPin = 13;
int dataPin = 11;
// Shift register pins for digit enable (16 outputs)
int latchPin2 = 5;
int clockPin2 = 6;
int dataPin2 = 4;
// Shift register pins for day-of-week indicator
int latchPin3 = A0;
int clockPin3 = A1;
int dataPin3 = A2;
int digit_code = 0;
int week_day = 0;
// New pins for AM/PM indicator and 7-seg decimal point (segDP)
const int ampmPin = 2; // Unused digital pin for AM/PM indicator
const int segDPPin = 3; // Unused digital pin for controlling segDP
//---------------------------------------------------------------------
// Revised dayofweek() function:
// Assumes rtc.now().dayOfTheWeek() returns 0 for Sunday, 1 for Monday, …, 6 for Saturday.
// Returns a bit mask with bit0 for Sunday, bit1 for Monday, …, bit6 for Saturday.
int dayofweek (int y) {
if (y < 0 || y > 6) return 0;
return 1 << y; // For example, if y==0, returns 1 (binary 00000001); if y==6, returns 64 (binary 01000000)
}
void getDate(char *psz)
// Date Setup: Code for reading clock date
{
char szBuf[10];
dd=Clock.getDate();
mm=Clock.getMonth(Century); //12
yyy=Clock.getYear();
sprintf(psz, "%d %s %04d",dd , mon2str(mm, szBuf, sizeof(szBuf)-1),(yyy + 2000));
}
void setup(void)
{
P.begin(2);
P.setInvert(false); //we don't want to invert anything so it is set to false
Wire.begin();
P.setZone(0, MAX_DEVICES-4, MAX_DEVICES-1);
P.setZone(1, MAX_DEVICES-4, MAX_DEVICES-1);
P.displayZoneText(1, szTime, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0,PA_PRINT , PA_NO_EFFECT);
P.addChar('$', degC);
P.addChar('&', degF);
}
void loop(void)
{
static uint32_t lastTime = 0; // millis() memory
static uint8_t display = 0; // current display mode
static bool flasher = false; // seconds passing flasher
P.displayAnimate();
if (P.getZoneStatus(0))
{
switch (display)
{
case 0: // Temperature deg C
P.setPause(0,1000);
P.setTextEffect(0, PA_OPENING, PA_CLOSING);
//P.setTextEffect(0, PA_MESH, PA_BLINDS);
display++;
dtostrf(Clock.getTemperature(), 3, 1, szMesg);
strcat(szMesg, "$");
//strcat(szMesg, "26.5$");
break;
case 1: // Temperature deg F
P.setTextEffect(0, PA_OPENING, PA_CLOSING);
//P.setTextEffect(0, PA_OPENING, PA_GROW_DOWN);
display++;
dtostrf((1.8 *Clock.getTemperature() )+32, 3, 1, szMesg);
strcat(szMesg, "&");
// strcpy(szMesg, "71.6&");
break;
case 2: // Clock
P.setFont(0, numeric7Seg);
P.setTextEffect(0, PA_PRINT, PA_NO_EFFECT);
//Sleep Mode
//Uncomment to enable Sleep Mode and adjust the hours to your needs
/*if (h==12 || h<8)//Time intervals (in this case, from 12AM to 8AM)
{
P.setIntensity(0); //Set display brightness to lowest setting
}
else
{
P.setIntensity(3); //Set display brightness to 6 (15 is the brighest)
}*/
P.setPause(0,0);
if (millis() - lastTime >= 1000)
{
lastTime = millis();
getTime(szMesg, flasher);
flasher = !flasher;
}
if(s==00&& s<=30){
display++;
P.setTextEffect(0, PA_PRINT, PA_SCROLL_UP);
}
// strcpy(szMesg, "36 % RH");
break;
case 3: // day of week
P.setFont(0,nullptr);
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
dow2str(Clock.getDoW()+1, szMesg, MAX_MESG); // Added +1 to get correct DoW
//dow2str(5, szMesg, MAX_MESG);
break;
default: // Calendar
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display = 0;
getDate(szMesg);
break;
}
P.displayReset(0);
}
'