My Arduino is hanging

Hi i am pradeep. I am using arduino since 3 years. I have used arduino for different application. But since last 6 months i am struck with arduino. I am using arduino for solar tracker means rotating panels using 24v dc motor actuator. For driving motor I am using dc motor driver from cytron manufacturers. Link is (Buy Cytron MD10C 13A Enhanced DC Motor Driver Online at the Best Price). Can anyone suggest me what is the problem in my design and code.

#include "CytronMotorDriver.h" // cytron library for DC motor rotation
#include<SoftwareSerial.h> // Software serial library for HC05 bluetooth interface
//#include "SparkFun_MMA8452Q.h"
//MMA8452Q accel;
#include <MPU6050_tockn.h> // Accelerometer library
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
//////////////////////////////////////////////////////////////////////////////
MPU6050 mpu6050(Wire);
SoftwareSerial Bluetooth(10, 11);
CytronMD motor(PWM_DIR, 3, 2);
///////////////////////////////////////////////////////////////////////////////
#define SET 1
#define CLEAR 0
#define MIN 01
#define SEC 01
#define ON 0
#define OFF 1
#define sec 1
////////////////////////////////////////////////////////////////////////////////
#define Bluetooth_stats 12 // read the status of bluetooth weather client is connected or not
int angle; // MPU6050 real angels in degrees
byte disableAutoFlag = 3; // to override motor in clockwise or anticlockwise direction during scheduled time

// variables used as flag to know dc motor run or stop
byte ret60, ret61, ret62, ret63, ret64, ret65, ret66, ret67, ret68, ret69, ret610, ret611,
ret70, ret71, ret72, ret73, ret74, ret75, ret76, ret77, ret78, ret79, ret710, ret711,
ret80, ret81, ret82, ret83, ret84, ret85, ret86, ret87, ret88, ret89, ret810, ret811,
ret90, ret91, ret92, ret93, ret94, ret95, ret96, ret97, ret98, ret99, ret910, ret911,
ret100, ret101, ret102, ret103, ret104, ret105, ret106, ret107, ret108, ret109, ret1010, ret1011,
ret110, ret111, ret112, ret113, ret114, ret115, ret116, ret117, ret118, ret119, ret1110, ret1111,
ret120, ret121, ret122, ret123, ret124, ret125, ret126, ret127, ret128, ret129, ret1210, ret1211,
ret130, ret131, ret132, ret133, ret134, ret135, ret136, ret137, ret138, ret139, ret1310, ret1311,
ret140, ret141, ret142, ret143, ret144, ret145, ret146, ret147, ret148, ret149, ret1410, ret1411,
ret150, ret151, ret152, ret153, ret154, ret155, ret156, ret157, ret158, ret159, ret1510, ret1511,
ret160, ret161, ret162, ret163, ret164, ret165, ret166, ret167, ret168, ret169, ret1610, ret1611,
ret170, ret171, ret172, ret173, ret174, ret175, ret176, ret177, ret178, ret179, ret1710, ret1711,
ret180, ret181, ret182, ret183, ret184, ret185, ret186, ret187, ret188, ret189, ret1810, ret1811,
ret230,
ret200;
//////////////////////////////////////////////////////////////////////////////////////

int onOrOffFlag = ON;

int Year = 0, c_hour = 0, c_minute = 0, c_second = 0, Angle_Degree = 0; // variables used to store timestamp and angle

byte on_HouR = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
byte on_MinTe = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59
};

byte off_HouR = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
byte off_MinTe = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59
};

String Time[5]; // used in functions to store splited timestamp into hr;min;sec
String string; // used to read data from bluetooth
int readdata;
byte Bluetooth_connect_flag = 0 ;

////////////////////////////////long type declarations for bluetooth dats read//////////////////
unsigned long Blue_thmillis_strt;
unsigned long Blue_thmillis_stop;

//////////////////////////Timer function scheduling////////////////////////
byte loadHandler(byte, byte , byte , byte , byte , byte , byte , byte , byte );
typedef struct userTime
{
byte temp_hour;
byte temp_minute;
byte temp_second;
} userTime_t;
unsigned char checkLessThanOrEqual(userTime_t , userTime_t);

/////////////////////////////////////////////////////////////////////////////
void setup() {
// put your setup code here, to run once:
Wire.begin();
Bluetooth.begin(9600);
Serial.begin(9600);
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
pinMode(Bluetooth_stats, INPUT);
// if (accel.begin() == false) {
// Bluetooth.println("ANG not Connected");
// while (1);
// }
}
//////////////////////////////LOOP////////////////
void loop() {

get_Angle();
get_time();
timecheck();
setflags();
bluetooth_part();

if (disableAutoFlag == 1)
{
clockwise_Mode();
}

if (disableAutoFlag == 2)
{
anti_clockwise_Mode();
}
}
////////////////////////////////////////LOOP///////////////
void timecheck()
{
tmElements_t tm;
if (RTC.read(tm))
{
c_hour = tm.Hour;
c_minute = tm.Minute;
c_second = tm.Second;
if (disableAutoFlag == 3)
{
ret60 = loadHandler( on_HouR[6], on_MinTe[0], sec, off_HouR[6], off_MinTe[2], sec, c_hour, c_minute, c_second);//-1------6:1 to 6:2
ret61 = loadHandler( on_HouR[6], on_MinTe[5], sec, off_HouR[6], off_MinTe[7], sec, c_hour, c_minute, c_second);//-2------6:4 to 6:5
ret62 = loadHandler( on_HouR[6], on_MinTe[10], sec, off_HouR[6], off_MinTe[12], sec, c_hour, c_minute, c_second);//-3------6:7 to 6:8
ret63 = loadHandler( on_HouR[6], on_MinTe[15], sec, off_HouR[6], off_MinTe[17], sec, c_hour, c_minute, c_second);//-4-----6:11 to 6:12
ret64 = loadHandler( on_HouR[6], on_MinTe[20], sec, off_HouR[6], off_MinTe[22], sec, c_hour, c_minute, c_second);//-5------6:14 to 6:15
ret65 = loadHandler( on_HouR[6], on_MinTe[25], sec, off_HouR[6], off_MinTe[27], sec, c_hour, c_minute, c_second);//-6------6:20 to 6:21
ret66 = loadHandler( on_HouR[6], on_MinTe[30], sec, off_HouR[6], off_MinTe[32], sec, c_hour, c_minute, c_second);//-7------6:25 to 6:26
ret67 = loadHandler( on_HouR[6], on_MinTe[35], sec, off_HouR[6], off_MinTe[37], sec, c_hour, c_minute, c_second);//-8------6:30 to 6:31
ret68 = loadHandler( on_HouR[6], on_MinTe[40], sec, off_HouR[6], off_MinTe[42], sec, c_hour, c_minute, c_second);//-9------6:35 to 6:36
ret69 = loadHandler( on_HouR[6], on_MinTe[45], sec, off_HouR[6], off_MinTe[47], sec, c_hour, c_minute, c_second);//-10-----6:42 to 6:43
ret610 = loadHandler( on_HouR[6], on_MinTe[50], sec, off_HouR[6], off_MinTe[52], sec, c_hour, c_minute, c_second);//-11----6:50 to 6:51
ret611 = loadHandler( on_HouR[6], on_MinTe[55], sec, off_HouR[6], off_MinTe[57], sec, c_hour, c_minute, c_second);//-12----6:56 to 6:57

  ret70 = loadHandler( on_HouR[7], on_MinTe[0], sec, off_HouR[7], off_MinTe[2], sec, c_hour, c_minute, c_second);//-13-----7:1 to 7:2
  ret71 = loadHandler( on_HouR[7], on_MinTe[5], sec, off_HouR[7], off_MinTe[7], sec, c_hour, c_minute, c_second);//-14-----7:4 to 7:5
  ret72 = loadHandler( on_HouR[7], on_MinTe[10], sec, off_HouR[7], off_MinTe[12], sec, c_hour, c_minute, c_second);//-15-----7:7 to 7:8
  ret73 = loadHandler( on_HouR[7], on_MinTe[15], sec, off_HouR[7], off_MinTe[17], sec, c_hour, c_minute, c_second);//-16----7:11 to 7:12
  ret74 = loadHandler( on_HouR[7], on_MinTe[20], sec, off_HouR[7], off_MinTe[22], sec, c_hour, c_minute, c_second);//-17----7:16 to 7:17
  ret75 = loadHandler( on_HouR[7], on_MinTe[25], sec, off_HouR[7], off_MinTe[27], sec, c_hour, c_minute, c_second);//-18-----7:20 to 7:21
  ret76 = loadHandler( on_HouR[7], on_MinTe[30], sec, off_HouR[7], off_MinTe[32], sec, c_hour, c_minute, c_second);//-19------7:26 to 7:27
  ret77 = loadHandler( on_HouR[7], on_MinTe[35], sec, off_HouR[7], off_MinTe[37], sec, c_hour, c_minute, c_second);//-20------7:30 to 7:31
  ret78 = loadHandler( on_HouR[7], on_MinTe[40], sec, off_HouR[7], off_MinTe[42], sec, c_hour, c_minute, c_second);//-21------7:36 to 7:37
  ret79 = loadHandler( on_HouR[7], on_MinTe[45], sec, off_HouR[7], off_MinTe[47], sec, c_hour, c_minute, c_second);//-22------7:42 to 7:43
  ret710 = loadHandler( on_HouR[7], on_MinTe[50], sec, off_HouR[7], off_MinTe[52], sec, c_hour, c_minute, c_second);//-23-----7:45 to 7:46
  ret711 = loadHandler( on_HouR[7], on_MinTe[55], sec, off_HouR[7], off_MinTe[57], sec, c_hour, c_minute, c_second);//-24-----7:48 to 7:49
  //    ret712 = loadHandler( on_HouR[7], on_MinTe[50], sec, off_HouR[7], off_MinTe[52], sec, c_hour, c_minute, c_second);//-25-----7:51 to 7:52
  //    ret713 = loadHandler( on_HouR[7], on_MinTe[53], sec, off_HouR[7], off_MinTe[55], sec, c_hour, c_minute, c_second);//-26-----7:54 to 7:55
  //    ret714 = loadHandler( on_HouR[7], on_MinTe[56], sec, off_HouR[7], off_MinTe[58], sec, c_hour, c_minute, c_second);//-27-----7:57 to 7:58

  ret80 = loadHandler( on_HouR[8], on_MinTe[0], sec, off_HouR[8], off_MinTe[2], sec, c_hour, c_minute, c_second);//-26------8:1 to 8:2
  ret81 = loadHandler( on_HouR[8], on_MinTe[5], sec, off_HouR[8], off_MinTe[7], sec, c_hour, c_minute, c_second);//-14-----7:4 to 7:5
  ret82 = loadHandler( on_HouR[8], on_MinTe[10], sec, off_HouR[8], off_MinTe[12], sec, c_hour, c_minute, c_second);//-15-----7:7 to 7:8
  ret83 = loadHandler( on_HouR[8], on_MinTe[15], sec, off_HouR[8], off_MinTe[17], sec, c_hour, c_minute, c_second);//-16----7:11 to 7:12
  ret84 = loadHandler( on_HouR[8], on_MinTe[20], sec, off_HouR[8], off_MinTe[22], sec, c_hour, c_minute, c_second);//-17----7:16 to 7:17
  ret85 = loadHandler( on_HouR[8], on_MinTe[25], sec, off_HouR[8], off_MinTe[27], sec, c_hour, c_minute, c_second);//-18-----7:20 to 7:21
  ret86 = loadHandler( on_HouR[8], on_MinTe[30], sec, off_HouR[8], off_MinTe[32], sec, c_hour, c_minute, c_second);//-19------7:26 to 7:27
  ret87 = loadHandler( on_HouR[8], on_MinTe[35], sec, off_HouR[8], off_MinTe[37], sec, c_hour, c_minute, c_second);//-20------7:30 to 7:31
  ret88 = loadHandler( on_HouR[8], on_MinTe[40], sec, off_HouR[8], off_MinTe[42], sec, c_hour, c_minute, c_second);//-21------7:36 to 7:37
  ret89 = loadHandler( on_HouR[8], on_MinTe[45], sec, off_HouR[8], off_MinTe[47], sec, c_hour, c_minute, c_second);//-22------7:42 to 7:43
  ret810 = loadHandler( on_HouR[8], on_MinTe[50], sec, off_HouR[8], off_MinTe[52], sec, c_hour, c_minute, c_second);//-23-----7:45 to 7:46
  ret811 = loadHandler( on_HouR[8], on_MinTe[55], sec, off_HouR[8], off_MinTe[57], sec, c_hour, c_minute, c_second);//-24-----7:48 to 7:49

  ret90 = loadHandler( on_HouR[9], on_MinTe[0], sec, off_HouR[9], off_MinTe[2], sec, c_hour, c_minute, c_second);//-25------9:1 to 9:2
  ret91 = loadHandler( on_HouR[9], on_MinTe[5], sec, off_HouR[9], off_MinTe[7], sec, c_hour, c_minute, c_second);//-14-----7:4 to 7:5
  ret92 = loadHandler( on_HouR[9], on_MinTe[10], sec, off_HouR[9], off_MinTe[12], sec, c_hour, c_minute, c_second);//-15-----7:7 to 7:8
  ret93 = loadHandler( on_HouR[9], on_MinTe[15], sec, off_HouR[9], off_MinTe[17], sec, c_hour, c_minute, c_second);//-16----7:11 to 7:12
  ret94 = loadHandler( on_HouR[9], on_MinTe[20], sec, off_HouR[9], off_MinTe[22], sec, c_hour, c_minute, c_second);//-17----7:16 to 7:17
  ret95 = loadHandler( on_HouR[9], on_MinTe[25], sec, off_HouR[9], off_MinTe[27], sec, c_hour, c_minute, c_second);//-18-----7:20 to 7:21
  ret96 = loadHandler( on_HouR[9], on_MinTe[30], sec, off_HouR[9], off_MinTe[32], sec, c_hour, c_minute, c_second);//-19------7:26 to 7:27
  ret97 = loadHandler( on_HouR[9], on_MinTe[35], sec, off_HouR[9], off_MinTe[37], sec, c_hour, c_minute, c_second);//-20------7:30 to 7:31
  ret98 = loadHandler( on_HouR[9], on_MinTe[40], sec, off_HouR[9], off_MinTe[42], sec, c_hour, c_minute, c_second);//-21------7:36 to 7:37
  ret99 = loadHandler( on_HouR[9], on_MinTe[45], sec, off_HouR[9], off_MinTe[47], sec, c_hour, c_minute, c_second);//-22------7:42 to 7:43
  ret910 = loadHandler( on_HouR[9], on_MinTe[50], sec, off_HouR[9], off_MinTe[52], sec, c_hour, c_minute, c_second);//-23-----7:45 to 7:46
  ret911 = loadHandler( on_HouR[9], on_MinTe[55], sec, off_HouR[9], off_MinTe[57], sec, c_hour, c_minute, c_second);//-24-----7:48 to 7:49

  ret100 = loadHandler( on_HouR[10], on_MinTe[0], sec, off_HouR[10], off_MinTe[2], sec, c_hour, c_minute, c_second);//-24----10:1 to 10:2
  ret101 = loadHandler( on_HouR[10], on_MinTe[5], sec, off_HouR[10], off_MinTe[7], sec, c_hour, c_minute, c_second);//-23-----10:4 to 10:5
  ret102 = loadHandler( on_HouR[10], on_MinTe[10], sec, off_HouR[10], off_MinTe[12], sec, c_hour, c_minute, c_second);//-22-----10:7 to 10:8
  ret103 = loadHandler( on_HouR[10], on_MinTe[15], sec, off_HouR[10], off_MinTe[17], sec, c_hour, c_minute, c_second);//-21-----10:11 to 10:12
  ret104 = loadHandler( on_HouR[10], on_MinTe[20], sec, off_HouR[10], off_MinTe[22], sec, c_hour, c_minute, c_second);//-20----10:16 to 10:17
  ret105 = loadHandler( on_HouR[10], on_MinTe[25], sec, off_HouR[10], off_MinTe[27], sec, c_hour, c_minute, c_second);//-19-----10:20 to 10:21
  ret106 = loadHandler( on_HouR[10], on_MinTe[30], sec, off_HouR[10], off_MinTe[32], sec, c_hour, c_minute, c_second);//-18------10:26 to 10:27
  ret107 = loadHandler( on_HouR[10], on_MinTe[35], sec, off_HouR[10], off_MinTe[37], sec, c_hour, c_minute, c_second);//-17-----10:30 to 10:31
  ret108 = loadHandler( on_HouR[10], on_MinTe[40], sec, off_HouR[10], off_MinTe[42], sec, c_hour, c_minute, c_second);//-16-----10:42 to 10:43
  ret109 = loadHandler( on_HouR[10], on_MinTe[45], sec, off_HouR[10], off_MinTe[47], sec, c_hour, c_minute, c_second);//-15-------10:45 to 10:46
  ret1010 = loadHandler( on_HouR[10], on_MinTe[50], sec, off_HouR[10], off_MinTe[52], sec, c_hour, c_minute, c_second);//-14-----10:51 to 10:52
  ret1011 = loadHandler( on_HouR[10], on_MinTe[55], sec, off_HouR[10], off_MinTe[57], sec, c_hour, c_minute, c_second);//-13-----10:54 to 10:55


  ret110 = loadHandler( on_HouR[11], on_MinTe[0], sec, off_HouR[11], off_MinTe[2], sec, c_hour, c_minute, c_second);//-12-----11:1 to 11:2
  ret111 = loadHandler( on_HouR[11], on_MinTe[5], sec, off_HouR[11], off_MinTe[7], sec, c_hour, c_minute, c_second);//-11-----11:4 to 11:5
  ret112 = loadHandler( on_HouR[11], on_MinTe[10], sec, off_HouR[11], off_MinTe[12], sec, c_hour, c_minute, c_second);//-10-----11:7 to 11:8
  ret113 = loadHandler( on_HouR[11], on_MinTe[15], sec, off_HouR[11], off_MinTe[17], sec, c_hour, c_minute, c_second);//-9-----11:11 to 11:12
  ret114 = loadHandler( on_HouR[11], on_MinTe[20], sec, off_HouR[11], off_MinTe[22], sec, c_hour, c_minute, c_second);//-8-----11:16 to 11:17
  ret115 = loadHandler( on_HouR[11], on_MinTe[25], sec, off_HouR[11], off_MinTe[27], sec, c_hour, c_minute, c_second);//-7-----11:26 to 11:27
  ret116 = loadHandler( on_HouR[11], on_MinTe[30], sec, off_HouR[11], off_MinTe[32], sec, c_hour, c_minute, c_second);//-6-----11:30 to 11:31
  ret117 = loadHandler( on_HouR[11], on_MinTe[35], sec, off_HouR[11], off_MinTe[37], sec, c_hour, c_minute, c_second);//-5-----11:42 to 11:43
  ret118 = loadHandler( on_HouR[11], on_MinTe[40], sec, off_HouR[11], off_MinTe[42], sec, c_hour, c_minute, c_second);//-4-----11:45 to 11:46
  ret119 = loadHandler( on_HouR[11], on_MinTe[45], sec, off_HouR[11], off_MinTe[47], sec, c_hour, c_minute, c_second);//-3-----11:51 to 11:52
  ret1110 = loadHandler( on_HouR[11], on_MinTe[50], sec, off_HouR[11], off_MinTe[52], sec, c_hour, c_minute, c_second);//-2---11:54 to 11:55
  ret1111 = loadHandler( on_HouR[11], on_MinTe[55], sec, off_HouR[11], off_MinTe[57], sec, c_hour, c_minute, c_second); //-1----11:57 to 11:58

  ret120 = loadHandler( on_HouR[12], on_MinTe[0], sec, off_HouR[12], off_MinTe[2], sec, c_hour, c_minute, c_second);//0----12:1 to 12:2
  ret121 = loadHandler( on_HouR[12], on_MinTe[5], sec, off_HouR[12], off_MinTe[7], sec, c_hour, c_minute, c_second);//-11-----11:4 to 11:5
  ret122 = loadHandler( on_HouR[12], on_MinTe[10], sec, off_HouR[12], off_MinTe[12], sec, c_hour, c_minute, c_second);//-10-----11:7 to 11:8
  ret123 = loadHandler( on_HouR[12], on_MinTe[15], sec, off_HouR[12], off_MinTe[17], sec, c_hour, c_minute, c_second);//-9-----11:11 to 11:12
  ret124 = loadHandler( on_HouR[12], on_MinTe[20], sec, off_HouR[12], off_MinTe[22], sec, c_hour, c_minute, c_second);//-8-----11:16 to 11:17
  ret125 = loadHandler( on_HouR[12], on_MinTe[25], sec, off_HouR[12], off_MinTe[27], sec, c_hour, c_minute, c_second);//-7-----11:26 to 11:27
  ret126 = loadHandler( on_HouR[12], on_MinTe[30], sec, off_HouR[12], off_MinTe[32], sec, c_hour, c_minute, c_second);//-6-----11:30 to 11:31
  ret127 = loadHandler( on_HouR[12], on_MinTe[35], sec, off_HouR[12], off_MinTe[37], sec, c_hour, c_minute, c_second);//-5-----11:42 to 11:43
  ret128 = loadHandler( on_HouR[12], on_MinTe[40], sec, off_HouR[12], off_MinTe[42], sec, c_hour, c_minute, c_second);//-4-----11:45 to 11:46
  ret129 = loadHandler( on_HouR[12], on_MinTe[45], sec, off_HouR[12], off_MinTe[47], sec, c_hour, c_minute, c_second);//-3-----11:51 to 11:52
  ret1210 = loadHandler( on_HouR[12], on_MinTe[50], sec, off_HouR[12], off_MinTe[52], sec, c_hour, c_minute, c_second);//-2---11:54 to 11:55
  ret1211 = loadHandler( on_HouR[12], on_MinTe[55], sec, off_HouR[12], off_MinTe[57], sec, c_hour, c_minute, c_second); //-1----11:57 to 11:58

  ret130 = loadHandler( on_HouR[13], on_MinTe[0], sec, off_HouR[13], off_MinTe[2], sec, c_hour, c_minute, c_second);//1-----13:1 to 13:2
  ret131 = loadHandler( on_HouR[13], on_MinTe[5], sec, off_HouR[13], off_MinTe[7], sec, c_hour, c_minute, c_second);//2-----13:4 to 13:5
  ret132 = loadHandler( on_HouR[13], on_MinTe[10], sec, off_HouR[13], off_MinTe[12], sec, c_hour, c_minute, c_second);//3------13:7 to 13:8
  ret133 = loadHandler( on_HouR[13], on_MinTe[15], sec, off_HouR[13], off_MinTe[17], sec, c_hour, c_minute, c_second);//4------13:11 to 13:12
  ret134 = loadHandler( on_HouR[13], on_MinTe[20], sec, off_HouR[13], off_MinTe[22], sec, c_hour, c_minute, c_second);//5-----13:21 to 13:22
  ret135 = loadHandler( on_HouR[13], on_MinTe[25], sec, off_HouR[13], off_MinTe[27], sec, c_hour, c_minute, c_second);//6-----13:26 to 13:27
  ret136 = loadHandler( on_HouR[13], on_MinTe[30], sec, off_HouR[13], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
  ret137 = loadHandler( on_HouR[13], on_MinTe[35], sec, off_HouR[13], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
  ret138 = loadHandler( on_HouR[13], on_MinTe[40], sec, off_HouR[13], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
  ret139 = loadHandler( on_HouR[13], on_MinTe[45], sec, off_HouR[13], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
  ret1310 = loadHandler( on_HouR[13], on_MinTe[50], sec, off_HouR[13], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
  ret1311 = loadHandler( on_HouR[13], on_MinTe[55], sec, off_HouR[13], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

  ret140 = loadHandler( on_HouR[14], on_MinTe[0], sec, off_HouR[14], off_MinTe[2], sec, c_hour, c_minute, c_second);//13//----14:1 to 14:2
  ret141 = loadHandler( on_HouR[14], on_MinTe[5], sec, off_HouR[14], off_MinTe[7], sec, c_hour, c_minute, c_second);//14--------14:4 to 14:5
  ret142 = loadHandler( on_HouR[14], on_MinTe[10], sec, off_HouR[14], off_MinTe[12], sec, c_hour, c_minute, c_second);//15-------14:9 to 14:10
  ret143 = loadHandler( on_HouR[14], on_MinTe[15], sec, off_HouR[14], off_MinTe[17], sec, c_hour, c_minute, c_second);//16-----14:11 to 14:12
  ret144 = loadHandler( on_HouR[14], on_MinTe[20], sec, off_HouR[14], off_MinTe[22], sec, c_hour, c_minute, c_second);//17------14:16 to 14:17
  ret145 = loadHandler( on_HouR[14], on_MinTe[25], sec, off_HouR[14], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------14:31 to 14:32
  ret146 = loadHandler( on_HouR[14], on_MinTe[30], sec, off_HouR[14], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
  ret147 = loadHandler( on_HouR[14], on_MinTe[35], sec, off_HouR[14], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
  ret148 = loadHandler( on_HouR[14], on_MinTe[40], sec, off_HouR[14], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
  ret149 = loadHandler( on_HouR[14], on_MinTe[45], sec, off_HouR[14], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
  ret1410 = loadHandler( on_HouR[14], on_MinTe[50], sec, off_HouR[14], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
  ret1411 = loadHandler( on_HouR[14], on_MinTe[55], sec, off_HouR[14], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

  ret150 = loadHandler( on_HouR[15], on_MinTe[0], sec, off_HouR[15], off_MinTe[2], sec, c_hour, c_minute, c_second);//19------15:1 to 15:2
  ret151 = loadHandler( on_HouR[15], on_MinTe[5], sec, off_HouR[15], off_MinTe[7], sec, c_hour, c_minute, c_second);//20------15:11 to 15:12
  ret152 = loadHandler( on_HouR[15], on_MinTe[10], sec, off_HouR[15], off_MinTe[12], sec, c_hour, c_minute, c_second);//21-------15:16 to 15:17
  ret153 = loadHandler( on_HouR[15], on_MinTe[15], sec, off_HouR[15], off_MinTe[17], sec, c_hour, c_minute, c_second);//22------15:21 to 15:22
  ret154 = loadHandler( on_HouR[15], on_MinTe[20], sec, off_HouR[15], off_MinTe[22], sec, c_hour, c_minute, c_second);//23------15:31 to 15:32
  ret155 = loadHandler( on_HouR[15], on_MinTe[25], sec, off_HouR[15], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------14:31 to 14:32
  ret156 = loadHandler( on_HouR[15], on_MinTe[30], sec, off_HouR[15], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
  ret157 = loadHandler( on_HouR[15], on_MinTe[35], sec, off_HouR[15], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
  ret158 = loadHandler( on_HouR[15], on_MinTe[40], sec, off_HouR[15], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
  ret159 = loadHandler( on_HouR[15], on_MinTe[45], sec, off_HouR[15], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
  ret1510 = loadHandler( on_HouR[15], on_MinTe[50], sec, off_HouR[15], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
  ret1511 = loadHandler( on_HouR[15], on_MinTe[55], sec, off_HouR[15], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

  ret160 = loadHandler( on_HouR[16], on_MinTe[0], sec, off_HouR[16], off_MinTe[2], sec, c_hour, c_minute, c_second);//19------15:1 to 15:2
  ret161 = loadHandler( on_HouR[16], on_MinTe[5], sec, off_HouR[16], off_MinTe[12], sec, c_hour, c_minute, c_second);//20------15:11 to 15:12
  ret162 = loadHandler( on_HouR[16], on_MinTe[10], sec, off_HouR[16], off_MinTe[17], sec, c_hour, c_minute, c_second);//21-------15:16 to 15:17
  ret163 = loadHandler( on_HouR[16], on_MinTe[15], sec, off_HouR[16], off_MinTe[22], sec, c_hour, c_minute, c_second);//22------15:21 to 15:22
  ret164 = loadHandler( on_HouR[16], on_MinTe[20], sec, off_HouR[16], off_MinTe[32], sec, c_hour, c_minute, c_second);//23------15:31 to 15:32
  ret165 = loadHandler( on_HouR[16], on_MinTe[25], sec, off_HouR[16], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------14:31 to 14:32
  ret166 = loadHandler( on_HouR[16], on_MinTe[30], sec, off_HouR[16], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
  ret167 = loadHandler( on_HouR[16], on_MinTe[35], sec, off_HouR[16], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
  ret168 = loadHandler( on_HouR[16], on_MinTe[40], sec, off_HouR[16], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
  ret169 = loadHandler( on_HouR[16], on_MinTe[45], sec, off_HouR[16], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
  ret1610 = loadHandler( on_HouR[16], on_MinTe[50], sec, off_HouR[16], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
  ret1611 = loadHandler( on_HouR[16], on_MinTe[55], sec, off_HouR[16], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

  ret170 = loadHandler( on_HouR[17], on_MinTe[0], sec, off_HouR[17], off_MinTe[2], sec, c_hour, c_minute, c_second);//23--------17:1 to 17:2
  ret171 = loadHandler( on_HouR[17], on_MinTe[5], sec, off_HouR[17], off_MinTe[7], sec, c_hour, c_minute, c_second);//22--------17:6 to 17:7
  ret172 = loadHandler( on_HouR[17], on_MinTe[10], sec, off_HouR[17], off_MinTe[12], sec, c_hour, c_minute, c_second);//21------17:11 to 17:12
  ret173 = loadHandler( on_HouR[17], on_MinTe[15], sec, off_HouR[17], off_MinTe[17], sec, c_hour, c_minute, c_second);//20------17:14 to 17:15
  ret174 = loadHandler( on_HouR[17], on_MinTe[20], sec, off_HouR[17], off_MinTe[22], sec, c_hour, c_minute, c_second);//19------17:17 to 17:18
  ret175 = loadHandler( on_HouR[17], on_MinTe[25], sec, off_HouR[17], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------17:20 to 17:21
  ret176 = loadHandler( on_HouR[17], on_MinTe[30], sec, off_HouR[17], off_MinTe[32], sec, c_hour, c_minute, c_second);//17-------17:24 to 17:25
  ret177 = loadHandler( on_HouR[17], on_MinTe[35], sec, off_HouR[17], off_MinTe[37], sec, c_hour, c_minute, c_second);//16-------17:31 to 17:32
  ret178 = loadHandler( on_HouR[17], on_MinTe[40], sec, off_HouR[17], off_MinTe[42], sec, c_hour, c_minute, c_second);//15-------17:36 to 17:37
  ret179 = loadHandler( on_HouR[17], on_MinTe[45], sec, off_HouR[17], off_MinTe[47], sec, c_hour, c_minute, c_second);//14-------17:41 to 17:42
  ret1710 = loadHandler( on_HouR[17], on_MinTe[50], sec, off_HouR[17], off_MinTe[52], sec, c_hour, c_minute, c_second);//13------17:49 to 17:50
  ret1711 = loadHandler( on_HouR[17], on_MinTe[55], sec, off_HouR[17], off_MinTe[57], sec, c_hour, c_minute, c_second);//12------17:52 to 17:53

  ret180 = loadHandler( on_HouR[18], on_MinTe[0], sec, off_HouR[18], off_MinTe[2], sec, c_hour, c_minute, c_second);//11-------18:1 to 18:2
  ret181 = loadHandler( on_HouR[18], on_MinTe[5], sec, off_HouR[18], off_MinTe[7], sec, c_hour, c_minute, c_second);//10-----18:4 to 18:5
  ret182 = loadHandler( on_HouR[18], on_MinTe[10], sec, off_HouR[18], off_MinTe[12], sec, c_hour, c_minute, c_second);//9------18:7 to 18:8
  ret183 = loadHandler( on_HouR[18], on_MinTe[15], sec, off_HouR[18], off_MinTe[17], sec, c_hour, c_minute, c_second);//8------18:10 to 18:11
  ret184 = loadHandler( on_HouR[18], on_MinTe[20], sec, off_HouR[18], off_MinTe[22], sec, c_hour, c_minute, c_second);//7------18:14 to 18:15
  ret185 = loadHandler( on_HouR[18], on_MinTe[25], sec, off_HouR[18], off_MinTe[27], sec, c_hour, c_minute, c_second);//6-----18:17 to 18:18
  ret186 = loadHandler( on_HouR[18], on_MinTe[30], sec, off_HouR[18], off_MinTe[32], sec, c_hour, c_minute, c_second);//5-----18:20 to 18:21
  ret187 = loadHandler( on_HouR[18], on_MinTe[35], sec, off_HouR[18], off_MinTe[37], sec, c_hour, c_minute, c_second);//4-----18:23 to 18:24
  ret188 = loadHandler( on_HouR[18], on_MinTe[40], sec, off_HouR[18], off_MinTe[42], sec, c_hour, c_minute, c_second);//3-----18:26 to 18:27
  ret189 = loadHandler( on_HouR[18], on_MinTe[45], sec, off_HouR[18], off_MinTe[47], sec, c_hour, c_minute, c_second);//2-----18:30 to 18:31
  ret1810 = loadHandler( on_HouR[18], on_MinTe[50], sec, off_HouR[18], off_MinTe[52], sec, c_hour, c_minute, c_second);//1-----18:32 to 18:33
  ret1811 = loadHandler( on_HouR[18], on_MinTe[55], sec, off_HouR[18], off_MinTe[57], sec, c_hour, c_minute, c_second); //0----18:34 to 18:35

  ret200 = loadHandler( on_HouR[20], on_MinTe[0], sec, off_HouR[20], off_MinTe[2], sec, c_hour, c_minute, c_second);//0-------20:1 to 20:2

  ret230 = loadHandler( on_HouR[23], on_MinTe[0], sec, off_HouR[23], off_MinTe[2], sec, c_hour, c_minute, c_second);//0-----23:1 to 23:2
}

}
}

void setflags()
{
//////////////////////////////////////////////////////////////////////////////6AM///////////////////////////////////////////////
if (ret60 == 1)
{
setAngle(0);
}

else if (ret68 == 1)
{
setAngle(0);
}

else if (ret69 == 1)
{
setAngle(-1);
}

else if (ret610 == 1)
{
setAngle(-2);
}

else if (ret611 == 1)
{
setAngle(-3);
}

/////////////////////////////////////////////////////////////////////////7AM////////////////////////////////////////////////

else if (ret70 == 1)
{
setAngle(-4);
}

else if (ret71 == 1)
{
setAngle(-5);
}

else if (ret72 == 1)
{
setAngle(-6);
}

else if (ret73 == 1)
{
setAngle(-7);
}

else if (ret74 == 1)
{
setAngle(-8);
}

else if (ret75 == 1)
{
setAngle(-9);
}

else if (ret76 == 1)
{
setAngle(-10);
}

else if (ret77 == 1)
{
setAngle(-11);
}

else if (ret78 == 1)
{
setAngle(-13);
}

else if (ret79 == 1)
{
setAngle(-14);
}

else if (ret710 == 1)
{
setAngle(-16);
}

else if (ret711 == 1)
{
setAngle(-17);
}

////////////////////////////////////////////////////////////////////////////////////////8AM/////////////////////////////////////////////////////
else if (ret80 == 1)
{
setAngle(-18);
}

else if (ret81 == 1)
{
setAngle(-19);
}
else if (ret82 == 1)
{
setAngle(-20);
}
else if (ret83 == 1)
{
setAngle(-22);
}
else if (ret84 == 1)
{
setAngle(-24);
}
else if (ret85 == 1)
{
setAngle(-26);
}

else if (ret86 == 1)
{
setAngle(-27);
}

else if (ret87 == 1)
{
setAngle(-28);
}

else if (ret88 == 1)
{
setAngle(-29);
}

else if (ret89 == 1)
{
setAngle(-30);
}

else if (ret810 == 1)
{
setAngle(-31);
}

else if (ret811 == 1)
{
setAngle(-33);
}

////////////////////////////////////////////////////////////////////////////////////9AM///////////////////////////////////////////
else if (ret90 == 1)
{
setAngle(-35);
}

else if (ret91 == 1)
{
setAngle(-37);
}
else if (ret92 == 1)
{
setAngle(-39);
}

else if (ret93 == 1)
{
setAngle(-40);
}

else if (ret94 == 1)
{
setAngle(-41);
}

else if (ret95 == 1)
{
setAngle(-42);
}

else if (ret96 == 1)
{
setAngle(-43);
}

else if (ret97 == 1)
{
setAngle(-44);
}

else if (ret98 == 1)
{
setAngle(-45);
}

else if (ret99 == 1)
{
setAngle(-44);
}

else if (ret910 == 1)
{
setAngle(-43);
}

else if (ret911 == 1)
{
setAngle(-42);
}
////////////////////////////////////////////////////////////////////////////////10AM///////////////////////////////////////////////////////////////

else if (ret100 == 1)
{
setAngle(-41);
}

else if (ret101 == 1)
{
setAngle(-40);
}

else if (ret102 == 1)
{
setAngle(-39);
}

else if (ret103 == 1)
{
setAngle(-38);
}

else if (ret104 == 1)
{
setAngle(-36);
}

else if (ret105 == 1)
{
setAngle(-35);
}

else if (ret106 == 1)
{
setAngle(-34);
}

else if (ret107 == 1)
{
setAngle(-33);
}

else if (ret108 == 1)
{
setAngle(-32);
}

else if (ret109 == 1)
{
setAngle(-31);
}

else if (ret1010 == 1)
{
setAngle(-29);
}

else if (ret1011 == 1)
{
setAngle(-28);
}

/////////////////////////////////////////////////////////////////11AM//////////////////////////////
else if (ret110 == 1)
{
setAngle(-26);
}
else if (ret111 == 1)
{
setAngle(-25);
}
else if (ret112 == 1)
{
setAngle(-23);
}
else if (ret113 == 1)
{
setAngle(-22);
}
else if (ret114 == 1)
{
setAngle(-21);
}
else if (ret115 == 1)
{
setAngle(-20);
}

else if (ret116 == 1)
{
setAngle(-18);
}

else if (ret117 == 1)
{
setAngle(-16);
}
else if (ret118 == 1)
{
setAngle(-14);
}

else if (ret119 == 1)
{
setAngle(-13);
}

else if (ret1110 == 1)
{
setAngle(-12);
}

else if (ret1111 == 1)
{
setAngle(-10);
}

///////////////////////////////////////////////////12PM//////////////////////////////////////////////////
else if (ret120 == 1)
{
setAngle(-9);
}
else if (ret121 == 1)
{
setAngle(-8);
}
else if (ret122 == 1)
{
setAngle(-6);
}
else if (ret123 == 1)
{
setAngle(-5);
}
else if (ret124 == 1)
{
setAngle(-4);
}
else if (ret125 == 1)
{
setAngle(-3);
}

else if (ret126 == 1)
{
setAngle(-1);
}

else if (ret127 == 1)
{
setAngle(0);
}

//////////////////////////////////////////////////////////////////////////////1PM////////////////////////////////////////////////////

else if (ret130 == 1)
{
setAngle(0);
}

else if (ret131 == 1)
{
setAngle(1);
}

else if (ret132 == 1)
{
setAngle(3);
}
else if (ret133 == 1)
{
setAngle(4);
}

else if (ret134 == 1)
{
setAngle(6);
}

else if (ret135 == 1)
{
setAngle(8);
}

else if (ret136 == 1)
{
setAngle(9);
}

else if (ret137 == 1)
{
setAngle(10);
}

else if (ret138 == 1)
{
setAngle(11);
}

else if (ret139 == 1)
{
setAngle(13);
}

else if (ret1310 == 1)
{
setAngle(14);
}

else if (ret1311 == 1)
{
setAngle(16);
}

////////////////////////////////////////////////////////////////////2PM/////////////////////////////////////////

else if (ret140 == 1)
{
setAngle(17);
}

else if (ret141 == 1)
{
setAngle(18);
}

else if (ret142 == 1)
{
setAngle(20);
}

else if (ret143 == 1)
{
setAngle(21);
}

else if (ret144 == 1)
{
setAngle(22);
}

else if (ret145 == 1)
{
setAngle(23);
}

else if (ret146 == 1)
{
setAngle(24);
}

else if (ret147 == 1)
{
setAngle(26);
}

else if (ret148 == 1)
{
setAngle(28);
}

else if (ret149 == 1)
{
setAngle(29);
}

else if (ret1410 == 1)
{
setAngle(30);
}

else if (ret1411 == 1)
{
setAngle(31);
}
///////////////////////////////////////////////////////////////////////////3PM/////////////////////////////////////////////////////////////////////
else if (ret150 == 1)
{
setAngle(33);
}

else if (ret151 == 1)
{
setAngle(34);
}

else if (ret152 == 1)
{
setAngle(36);
}

else if (ret158 == 1)
{
setAngle(36);
}

else if (ret159 == 1)
{
setAngle(35);
}

else if (ret1510 == 1)
{
setAngle(34);
}

else if (ret1511 == 1)
{
setAngle(33);
}

///////////////////////////////////////////////////////////////////////////////5PM///////////////////////////////
else if (ret160 == 1)
{
setAngle(32);
}

else if (ret161 == 1)
{
setAngle(31);
}

else if (ret162 == 1)
{
setAngle(30);
}

else if (ret163 == 1)
{
setAngle(29);
}

else if (ret164 == 1)
{
setAngle(28);
}

else if (ret165 == 1)
{
setAngle(27);
}

else if (ret166 == 1)
{
setAngle(26);
}

else if (ret167 == 1)
{
setAngle(25);
}

else if (ret168 == 1)
{
setAngle(24);
}

else if (ret169 == 1)
{
setAngle(23);
}

else if (ret1610 == 1)
{
setAngle(22);
}

///////////////////////////////////////////////////////////////////////////////5PM///////////////////////////////
else if (ret170 == 1)
{
setAngle(21);
}

else if (ret172 == 1)
{
setAngle(20);
}

else if (ret174 == 1)
{
setAngle(19);
}

else if (ret177 == 1)
{
setAngle(18);
}

else if (ret178 == 1)
{
setAngle(17);
}

else if (ret179 == 1)
{
setAngle(16);
}
else if (ret1710 == 1)
{
setAngle(15);
}
else if (ret1711 == 1)
{
setAngle(13);
}

///////////////////////////////////////////////////////////////////6PM///////////////////////////////////////////
else if (ret180 == 1)
{
setAngle(11);
}
else if (ret181 == 1)
{
setAngle(9);
}
else if (ret182 == 1)
{
setAngle(7);
}
else if (ret183 == 1)
{
setAngle(4);
}
else if (ret184 == 1)
{
setAngle(2);
}
else if (ret185 == 1)
{
setAngle(0);
}

else if (ret1811 == 1)
{
setAngle(0);
}

////////////////////////////////////////////////////////////////////////////11PM////////////////////////////

else if (ret230 == 1)
{
setAngle(0);
}
/////////////////////////////////////////////////////else////////////////////
else
{
stop_Mode();
}
}

void setAngle(int angle1)
{
if (Angle_Degree < angle1)
{
clockwise_Mode();
}
else if (Angle_Degree > angle1)
{
anti_clockwise_Mode();
}
else if ((Angle_Degree == angle1))
{
stop_Mode();
}
}

///////////////////////////////////////////////////////////////////////////////////////////////
void get_Angle()
{
long angle_average = 0;
for (int i = 0; i < 250; i++)
{
mpu6050.update();
//angle_average += 90 * (accel.getCalculatedX());
angle_average += (int)(mpu6050.getAccAngleX());
}
Angle_Degree = (angle_average / 250);
angle_average = 0;
}

void get_time()
{
tmElements_t tm;
(RTC.read(tm));
c_hour = tm.Hour;
c_minute = tm.Minute;
c_second = tm.Second;
}

void clockwise_Mode()
{
// if (MD == 1)
// {
motor.setSpeed(-255);
//
// currentTime = millis();
// if ((unsigned long)(currentTime - previousTime) >= interval)
// {
// if (Angle_Degree != angle)
// {
// MD = 0;
// }
// else
// MD = 1;
// previousTime = currentTime;
// }
// }
}

void anti_clockwise_Mode()
{
motor.setSpeed(255);
}

void stop_Mode()
{
motor.setSpeed(0);
}

byte loadHandler(byte onTimeHr, byte onTimeMin, byte onTimeSec, byte offTimeHr, byte offTimeMin, byte offTimeSec, byte rtcTimeHr, byte rtcTimeMin, byte rtcTimeSec)
{
userTime_t in1 = {onTimeHr, onTimeMin, onTimeSec}, in2 = {offTimeHr, offTimeMin, offTimeSec}, rtc_hr = {rtcTimeHr, rtcTimeMin, rtcTimeSec}, a = {}, b = {};

if (checkLessThanOrEqual(in1, in2))
{
onOrOffFlag = ON;
memcpy(&a, &in1, sizeof(userTime_t));
memcpy(&b, &in2, sizeof(userTime_t));
}
else
{
onOrOffFlag = OFF;
memcpy(&a, &in2, sizeof(userTime_t));
memcpy(&b, &in1, sizeof(userTime_t));
}

if ((checkLessThanOrEqual(a, rtc_hr)) && (checkLessThanOrEqual(rtc_hr, b)))
{
if (onOrOffFlag == ON)
{
return HIGH;
}
else
{
return LOW;
}
}
else
{
if (onOrOffFlag == ON)
{
return LOW;
}
else
{
return HIGH;
}
}
}

unsigned char checkLessThanOrEqual(userTime_t a, userTime_t b)
{
if (a.temp_hour < b.temp_hour)
return true;
else
{
if ((a.temp_hour == b.temp_hour) && (a.temp_minute < b.temp_minute))
{
return true;
}
else
{
if (a.temp_hour > b.temp_hour)
return false;
else
{
if ((a.temp_minute == b.temp_minute) && (a.temp_second < b.temp_second))
{
return true;
}
else
{
if (a.temp_minute > b.temp_minute)
return false;
else
{
if (a.temp_second == b.temp_second)
{
return true;
}
else
{
return false;
}
}
}
}
}
}
}

void bluetooth_part()
{
readdata = digitalRead(Bluetooth_stats);
if (readdata == 1)
{
if (Bluetooth_connect_flag == 1)
{
Bluetooth.println("BT-CNCTD");
tmElements_t tm;
(RTC.read(tm));
Bluetooth.print("Time = ");
Bluetooth.print(tm.Hour);
Bluetooth.print(": ");
Bluetooth.print(tm.Minute);
Bluetooth.print(": ");
Bluetooth.println(tm.Second);
Bluetooth.print("Ang = ");
Bluetooth.println(Angle_Degree);
Bluetooth_connect_flag = 0;
}
}
else if ((readdata == 0) && (Bluetooth_connect_flag == 0))
{
Bluetooth_connect_flag = 1;
}
if (Bluetooth.available() > 0)
{
if (Bluetooth.find('*'))
{
Blue_thmillis_strt = millis();
string = "";
while (1)
{
Blue_thmillis_stop = millis();
char c = Bluetooth.read();
if ((c == '#') || ((Blue_thmillis_stop - Blue_thmillis_strt) > 2000))break;
string += c;
delay(10);
}
}
}
char n[1] = {};

String m = string.substring(0, 1);
m.toCharArray(n, 2);
switch (n[0])
{
case 'S':
tmElements_t tm;
Time[0] = string.substring(1, 3);
Time[1] = string.substring(4, 6);
Time[2] = string.substring(7, 9);
Time[3] = string.substring(10, 12);
Time[4] = string.substring(13, 15);
tm.Hour = Time[0].toInt();
tm.Minute = Time[1].toInt();
tm.Second = 00;
tm.Day = Time[2].toInt();
tm.Month = Time[3].toInt();
Year = Time[4].toInt() - 78;
tm.Year = CalendarYrToTm(Year);;
RTC.write(tm);
Bluetooth.println("TD: set to");
Bluetooth.print("Time = ");
Bluetooth.print(Time[0]);
Bluetooth.print(": ");
Bluetooth.print(Time[1]);
Bluetooth.print(": ");
Bluetooth.println("00");
Bluetooth.print("Date = ");
Bluetooth.print(Time[2]);
Bluetooth.print(" / ");
Bluetooth.print(Time[3]);
Bluetooth.print(" / ");
Bluetooth.println(Time[4]);
Time[0] = "";
Time[1] = "";
Time[2] = "";
Time[3] = "";
Time[4] = "";
string = "";
break;
case 'R':
(RTC.read(tm));
Bluetooth.print("Time = ");
Bluetooth.print(tm.Hour);
Bluetooth.print(": ");
Bluetooth.print(tm.Minute);
Bluetooth.print(": ");
Bluetooth.println(tm.Second);
Bluetooth.print("Angle = ");
Bluetooth.println(Angle_Degree);
string = "";
break;
case '1':
Bluetooth.print("CLK-WISE");
disableAutoFlag = 1;
//clockwise_Mode();
string = "";
break;
case 'T':
Bluetooth.print("ANTI-CLK");
disableAutoFlag = 2;
//anti_clockwise_Mode();
string = "";
break;
case '0':
Bluetooth.print("STOPPED");
disableAutoFlag = 3;
stop_Mode();
string = "";
break;
}
}

Your code is lacking both comments and code tags.

Code commented little bit. Is that enough or not?

No, it isn´t.
The sketch looks like code alá Bolognese.

at first glance, clever use of switch-case using fall through could shrink the code by about 90% !

You should use the auto-formatting of the IDE.

An array to hold all the retxx variables, and an array for the corresponding angles (or a struct with both) would make it a single for loop.

Why the on_HouR, on_MinTe, off_HouR, and off_MinTe arrays? No reason to use something like on_HouR[10] instead of just using 10 directly, and the on_MinTe/off_MinTe arrays make the code even more confusing because you need to specifiy number-1 to get number (as well as your comments do not match the numbers used). Once again, an array of struct for the on / off times would greatly simplify the code.

Learn to work with unix timestamps for comparisons, much easier than hours/minutes/seconds.

I think I'd be inclined to totally abandon the approach of checking so many short time ranges during the day and just create an array with the corresponding angle for each minute during the day (or find the equation for calculating the angle and use that, since the angle is not going to remain constant throughout the year).

Does your program now do anything for any amount of time?

You say vaguely what is for, can you give us a brief description of what the big idea is, that is what someone who doesn't know any programming might say to someone who does, so that person could then write a program?

Like

I need a device to feed my cat at certain amounts of food at various times of the day, but not if it is raining. Also the amounts depend on how much the cat weighs.


Also, I need to see on my iPhone the cat's current weight and when the last food was dispensed and how much food.

Like that. Short, no programming jargon, no preconceived ideas about how an engineer might need to proceed.

That is where you should start us, that is where you should start.

Also, yikes! Call this version 0.9 and light a fire to it, total redesign from the top to the bottom for version 1.0.

a7

OP's Code in tags after autoformat.

#include "CytronMotorDriver.h" // cytron library for DC motor rotation
#include<SoftwareSerial.h> // Software serial library for HC05 bluetooth interface
//#include "SparkFun_MMA8452Q.h"
//MMA8452Q accel;
#include <MPU6050_tockn.h> // Accelerometer library
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
//////////////////////////////////////////////////////////////////////////////
MPU6050 mpu6050(Wire);
SoftwareSerial Bluetooth(10, 11);
CytronMD motor(PWM_DIR, 3, 2);
///////////////////////////////////////////////////////////////////////////////
#define SET 1
#define CLEAR 0
#define MIN 01
#define SEC 01
#define ON 0
#define OFF 1
#define sec 1
////////////////////////////////////////////////////////////////////////////////
#define Bluetooth_stats 12 // read the status of bluetooth weather client is connected or not
int angle; // MPU6050 real angels in degrees
byte disableAutoFlag = 3; // to override motor in clockwise or anticlockwise direction during scheduled time

// variables used as flag to know dc motor run or stop
byte ret60, ret61, ret62, ret63, ret64, ret65, ret66, ret67, ret68, ret69, ret610, ret611,
     ret70, ret71, ret72, ret73, ret74, ret75, ret76, ret77, ret78, ret79, ret710, ret711,
     ret80, ret81, ret82, ret83, ret84, ret85, ret86, ret87, ret88, ret89, ret810, ret811,
     ret90, ret91, ret92, ret93, ret94, ret95, ret96, ret97, ret98, ret99, ret910, ret911,
     ret100, ret101, ret102, ret103, ret104, ret105, ret106, ret107, ret108, ret109, ret1010, ret1011,
     ret110, ret111, ret112, ret113, ret114, ret115, ret116, ret117, ret118, ret119, ret1110, ret1111,
     ret120, ret121, ret122, ret123, ret124, ret125, ret126, ret127, ret128, ret129, ret1210, ret1211,
     ret130, ret131, ret132, ret133, ret134, ret135, ret136, ret137, ret138, ret139, ret1310, ret1311,
     ret140, ret141, ret142, ret143, ret144, ret145, ret146, ret147, ret148, ret149, ret1410, ret1411,
     ret150, ret151, ret152, ret153, ret154, ret155, ret156, ret157, ret158, ret159, ret1510, ret1511,
     ret160, ret161, ret162, ret163, ret164, ret165, ret166, ret167, ret168, ret169, ret1610, ret1611,
     ret170, ret171, ret172, ret173, ret174, ret175, ret176, ret177, ret178, ret179, ret1710, ret1711,
     ret180, ret181, ret182, ret183, ret184, ret185, ret186, ret187, ret188, ret189, ret1810, ret1811,
     ret230,
     ret200;
//////////////////////////////////////////////////////////////////////////////////////

int onOrOffFlag = ON;

int Year = 0, c_hour = 0, c_minute = 0, c_second = 0, Angle_Degree = 0; // variables used to store timestamp and angle

byte on_HouR = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
byte on_MinTe = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
                 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
                 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
                 51, 52, 53, 54, 55, 56, 57, 58, 59
                };

byte off_HouR = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
byte off_MinTe = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                  11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
                  21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                  31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
                  41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
                  51, 52, 53, 54, 55, 56, 57, 58, 59
                 };

String Time[5]; // used in functions to store splited timestamp into hr;min;sec
String string; // used to read data from bluetooth
int readdata;
byte Bluetooth_connect_flag = 0 ;

////////////////////////////////long type declarations for bluetooth dats read//////////////////
unsigned long Blue_thmillis_strt;
unsigned long Blue_thmillis_stop;

//////////////////////////Timer function scheduling////////////////////////
byte loadHandler(byte, byte , byte , byte , byte , byte , byte , byte , byte );
typedef struct userTime
{
  byte temp_hour;
  byte temp_minute;
  byte temp_second;
} userTime_t;
unsigned char checkLessThanOrEqual(userTime_t , userTime_t);

/////////////////////////////////////////////////////////////////////////////
void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  Bluetooth.begin(9600);
  Serial.begin(9600);
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
  pinMode(Bluetooth_stats, INPUT);
  // if (accel.begin() == false) {
  // Bluetooth.println("ANG not Connected");
  // while (1);
  // }
}
//////////////////////////////LOOP////////////////
void loop() {

  get_Angle();
  get_time();
  timecheck();
  setflags();
  bluetooth_part();

  if (disableAutoFlag == 1)
  {
    clockwise_Mode();
  }

  if (disableAutoFlag == 2)
  {
    anti_clockwise_Mode();
  }
}
////////////////////////////////////////LOOP///////////////
void timecheck()
{
  tmElements_t tm;
  if (RTC.read(tm))
  {
    c_hour = tm.Hour;
    c_minute = tm.Minute;
    c_second = tm.Second;
    if (disableAutoFlag == 3)
    {
      ret60 = loadHandler( on_HouR[6], on_MinTe[0], sec, off_HouR[6], off_MinTe[2], sec, c_hour, c_minute, c_second);//-1------6:1 to 6:2
      ret61 = loadHandler( on_HouR[6], on_MinTe[5], sec, off_HouR[6], off_MinTe[7], sec, c_hour, c_minute, c_second);//-2------6:4 to 6:5
      ret62 = loadHandler( on_HouR[6], on_MinTe[10], sec, off_HouR[6], off_MinTe[12], sec, c_hour, c_minute, c_second);//-3------6:7 to 6:8
      ret63 = loadHandler( on_HouR[6], on_MinTe[15], sec, off_HouR[6], off_MinTe[17], sec, c_hour, c_minute, c_second);//-4-----6:11 to 6:12
      ret64 = loadHandler( on_HouR[6], on_MinTe[20], sec, off_HouR[6], off_MinTe[22], sec, c_hour, c_minute, c_second);//-5------6:14 to 6:15
      ret65 = loadHandler( on_HouR[6], on_MinTe[25], sec, off_HouR[6], off_MinTe[27], sec, c_hour, c_minute, c_second);//-6------6:20 to 6:21
      ret66 = loadHandler( on_HouR[6], on_MinTe[30], sec, off_HouR[6], off_MinTe[32], sec, c_hour, c_minute, c_second);//-7------6:25 to 6:26
      ret67 = loadHandler( on_HouR[6], on_MinTe[35], sec, off_HouR[6], off_MinTe[37], sec, c_hour, c_minute, c_second);//-8------6:30 to 6:31
      ret68 = loadHandler( on_HouR[6], on_MinTe[40], sec, off_HouR[6], off_MinTe[42], sec, c_hour, c_minute, c_second);//-9------6:35 to 6:36
      ret69 = loadHandler( on_HouR[6], on_MinTe[45], sec, off_HouR[6], off_MinTe[47], sec, c_hour, c_minute, c_second);//-10-----6:42 to 6:43
      ret610 = loadHandler( on_HouR[6], on_MinTe[50], sec, off_HouR[6], off_MinTe[52], sec, c_hour, c_minute, c_second);//-11----6:50 to 6:51
      ret611 = loadHandler( on_HouR[6], on_MinTe[55], sec, off_HouR[6], off_MinTe[57], sec, c_hour, c_minute, c_second);//-12----6:56 to 6:57

      ret70 = loadHandler( on_HouR[7], on_MinTe[0], sec, off_HouR[7], off_MinTe[2], sec, c_hour, c_minute, c_second);//-13-----7:1 to 7:2
      ret71 = loadHandler( on_HouR[7], on_MinTe[5], sec, off_HouR[7], off_MinTe[7], sec, c_hour, c_minute, c_second);//-14-----7:4 to 7:5
      ret72 = loadHandler( on_HouR[7], on_MinTe[10], sec, off_HouR[7], off_MinTe[12], sec, c_hour, c_minute, c_second);//-15-----7:7 to 7:8
      ret73 = loadHandler( on_HouR[7], on_MinTe[15], sec, off_HouR[7], off_MinTe[17], sec, c_hour, c_minute, c_second);//-16----7:11 to 7:12
      ret74 = loadHandler( on_HouR[7], on_MinTe[20], sec, off_HouR[7], off_MinTe[22], sec, c_hour, c_minute, c_second);//-17----7:16 to 7:17
      ret75 = loadHandler( on_HouR[7], on_MinTe[25], sec, off_HouR[7], off_MinTe[27], sec, c_hour, c_minute, c_second);//-18-----7:20 to 7:21
      ret76 = loadHandler( on_HouR[7], on_MinTe[30], sec, off_HouR[7], off_MinTe[32], sec, c_hour, c_minute, c_second);//-19------7:26 to 7:27
      ret77 = loadHandler( on_HouR[7], on_MinTe[35], sec, off_HouR[7], off_MinTe[37], sec, c_hour, c_minute, c_second);//-20------7:30 to 7:31
      ret78 = loadHandler( on_HouR[7], on_MinTe[40], sec, off_HouR[7], off_MinTe[42], sec, c_hour, c_minute, c_second);//-21------7:36 to 7:37
      ret79 = loadHandler( on_HouR[7], on_MinTe[45], sec, off_HouR[7], off_MinTe[47], sec, c_hour, c_minute, c_second);//-22------7:42 to 7:43
      ret710 = loadHandler( on_HouR[7], on_MinTe[50], sec, off_HouR[7], off_MinTe[52], sec, c_hour, c_minute, c_second);//-23-----7:45 to 7:46
      ret711 = loadHandler( on_HouR[7], on_MinTe[55], sec, off_HouR[7], off_MinTe[57], sec, c_hour, c_minute, c_second);//-24-----7:48 to 7:49
      //    ret712 = loadHandler( on_HouR[7], on_MinTe[50], sec, off_HouR[7], off_MinTe[52], sec, c_hour, c_minute, c_second);//-25-----7:51 to 7:52
      //    ret713 = loadHandler( on_HouR[7], on_MinTe[53], sec, off_HouR[7], off_MinTe[55], sec, c_hour, c_minute, c_second);//-26-----7:54 to 7:55
      //    ret714 = loadHandler( on_HouR[7], on_MinTe[56], sec, off_HouR[7], off_MinTe[58], sec, c_hour, c_minute, c_second);//-27-----7:57 to 7:58

      ret80 = loadHandler( on_HouR[8], on_MinTe[0], sec, off_HouR[8], off_MinTe[2], sec, c_hour, c_minute, c_second);//-26------8:1 to 8:2
      ret81 = loadHandler( on_HouR[8], on_MinTe[5], sec, off_HouR[8], off_MinTe[7], sec, c_hour, c_minute, c_second);//-14-----7:4 to 7:5
      ret82 = loadHandler( on_HouR[8], on_MinTe[10], sec, off_HouR[8], off_MinTe[12], sec, c_hour, c_minute, c_second);//-15-----7:7 to 7:8
      ret83 = loadHandler( on_HouR[8], on_MinTe[15], sec, off_HouR[8], off_MinTe[17], sec, c_hour, c_minute, c_second);//-16----7:11 to 7:12
      ret84 = loadHandler( on_HouR[8], on_MinTe[20], sec, off_HouR[8], off_MinTe[22], sec, c_hour, c_minute, c_second);//-17----7:16 to 7:17
      ret85 = loadHandler( on_HouR[8], on_MinTe[25], sec, off_HouR[8], off_MinTe[27], sec, c_hour, c_minute, c_second);//-18-----7:20 to 7:21
      ret86 = loadHandler( on_HouR[8], on_MinTe[30], sec, off_HouR[8], off_MinTe[32], sec, c_hour, c_minute, c_second);//-19------7:26 to 7:27
      ret87 = loadHandler( on_HouR[8], on_MinTe[35], sec, off_HouR[8], off_MinTe[37], sec, c_hour, c_minute, c_second);//-20------7:30 to 7:31
      ret88 = loadHandler( on_HouR[8], on_MinTe[40], sec, off_HouR[8], off_MinTe[42], sec, c_hour, c_minute, c_second);//-21------7:36 to 7:37
      ret89 = loadHandler( on_HouR[8], on_MinTe[45], sec, off_HouR[8], off_MinTe[47], sec, c_hour, c_minute, c_second);//-22------7:42 to 7:43
      ret810 = loadHandler( on_HouR[8], on_MinTe[50], sec, off_HouR[8], off_MinTe[52], sec, c_hour, c_minute, c_second);//-23-----7:45 to 7:46
      ret811 = loadHandler( on_HouR[8], on_MinTe[55], sec, off_HouR[8], off_MinTe[57], sec, c_hour, c_minute, c_second);//-24-----7:48 to 7:49

      ret90 = loadHandler( on_HouR[9], on_MinTe[0], sec, off_HouR[9], off_MinTe[2], sec, c_hour, c_minute, c_second);//-25------9:1 to 9:2
      ret91 = loadHandler( on_HouR[9], on_MinTe[5], sec, off_HouR[9], off_MinTe[7], sec, c_hour, c_minute, c_second);//-14-----7:4 to 7:5
      ret92 = loadHandler( on_HouR[9], on_MinTe[10], sec, off_HouR[9], off_MinTe[12], sec, c_hour, c_minute, c_second);//-15-----7:7 to 7:8
      ret93 = loadHandler( on_HouR[9], on_MinTe[15], sec, off_HouR[9], off_MinTe[17], sec, c_hour, c_minute, c_second);//-16----7:11 to 7:12
      ret94 = loadHandler( on_HouR[9], on_MinTe[20], sec, off_HouR[9], off_MinTe[22], sec, c_hour, c_minute, c_second);//-17----7:16 to 7:17
      ret95 = loadHandler( on_HouR[9], on_MinTe[25], sec, off_HouR[9], off_MinTe[27], sec, c_hour, c_minute, c_second);//-18-----7:20 to 7:21
      ret96 = loadHandler( on_HouR[9], on_MinTe[30], sec, off_HouR[9], off_MinTe[32], sec, c_hour, c_minute, c_second);//-19------7:26 to 7:27
      ret97 = loadHandler( on_HouR[9], on_MinTe[35], sec, off_HouR[9], off_MinTe[37], sec, c_hour, c_minute, c_second);//-20------7:30 to 7:31
      ret98 = loadHandler( on_HouR[9], on_MinTe[40], sec, off_HouR[9], off_MinTe[42], sec, c_hour, c_minute, c_second);//-21------7:36 to 7:37
      ret99 = loadHandler( on_HouR[9], on_MinTe[45], sec, off_HouR[9], off_MinTe[47], sec, c_hour, c_minute, c_second);//-22------7:42 to 7:43
      ret910 = loadHandler( on_HouR[9], on_MinTe[50], sec, off_HouR[9], off_MinTe[52], sec, c_hour, c_minute, c_second);//-23-----7:45 to 7:46
      ret911 = loadHandler( on_HouR[9], on_MinTe[55], sec, off_HouR[9], off_MinTe[57], sec, c_hour, c_minute, c_second);//-24-----7:48 to 7:49

      ret100 = loadHandler( on_HouR[10], on_MinTe[0], sec, off_HouR[10], off_MinTe[2], sec, c_hour, c_minute, c_second);//-24----10:1 to 10:2
      ret101 = loadHandler( on_HouR[10], on_MinTe[5], sec, off_HouR[10], off_MinTe[7], sec, c_hour, c_minute, c_second);//-23-----10:4 to 10:5
      ret102 = loadHandler( on_HouR[10], on_MinTe[10], sec, off_HouR[10], off_MinTe[12], sec, c_hour, c_minute, c_second);//-22-----10:7 to 10:8
      ret103 = loadHandler( on_HouR[10], on_MinTe[15], sec, off_HouR[10], off_MinTe[17], sec, c_hour, c_minute, c_second);//-21-----10:11 to 10:12
      ret104 = loadHandler( on_HouR[10], on_MinTe[20], sec, off_HouR[10], off_MinTe[22], sec, c_hour, c_minute, c_second);//-20----10:16 to 10:17
      ret105 = loadHandler( on_HouR[10], on_MinTe[25], sec, off_HouR[10], off_MinTe[27], sec, c_hour, c_minute, c_second);//-19-----10:20 to 10:21
      ret106 = loadHandler( on_HouR[10], on_MinTe[30], sec, off_HouR[10], off_MinTe[32], sec, c_hour, c_minute, c_second);//-18------10:26 to 10:27
      ret107 = loadHandler( on_HouR[10], on_MinTe[35], sec, off_HouR[10], off_MinTe[37], sec, c_hour, c_minute, c_second);//-17-----10:30 to 10:31
      ret108 = loadHandler( on_HouR[10], on_MinTe[40], sec, off_HouR[10], off_MinTe[42], sec, c_hour, c_minute, c_second);//-16-----10:42 to 10:43
      ret109 = loadHandler( on_HouR[10], on_MinTe[45], sec, off_HouR[10], off_MinTe[47], sec, c_hour, c_minute, c_second);//-15-------10:45 to 10:46
      ret1010 = loadHandler( on_HouR[10], on_MinTe[50], sec, off_HouR[10], off_MinTe[52], sec, c_hour, c_minute, c_second);//-14-----10:51 to 10:52
      ret1011 = loadHandler( on_HouR[10], on_MinTe[55], sec, off_HouR[10], off_MinTe[57], sec, c_hour, c_minute, c_second);//-13-----10:54 to 10:55


      ret110 = loadHandler( on_HouR[11], on_MinTe[0], sec, off_HouR[11], off_MinTe[2], sec, c_hour, c_minute, c_second);//-12-----11:1 to 11:2
      ret111 = loadHandler( on_HouR[11], on_MinTe[5], sec, off_HouR[11], off_MinTe[7], sec, c_hour, c_minute, c_second);//-11-----11:4 to 11:5
      ret112 = loadHandler( on_HouR[11], on_MinTe[10], sec, off_HouR[11], off_MinTe[12], sec, c_hour, c_minute, c_second);//-10-----11:7 to 11:8
      ret113 = loadHandler( on_HouR[11], on_MinTe[15], sec, off_HouR[11], off_MinTe[17], sec, c_hour, c_minute, c_second);//-9-----11:11 to 11:12
      ret114 = loadHandler( on_HouR[11], on_MinTe[20], sec, off_HouR[11], off_MinTe[22], sec, c_hour, c_minute, c_second);//-8-----11:16 to 11:17
      ret115 = loadHandler( on_HouR[11], on_MinTe[25], sec, off_HouR[11], off_MinTe[27], sec, c_hour, c_minute, c_second);//-7-----11:26 to 11:27
      ret116 = loadHandler( on_HouR[11], on_MinTe[30], sec, off_HouR[11], off_MinTe[32], sec, c_hour, c_minute, c_second);//-6-----11:30 to 11:31
      ret117 = loadHandler( on_HouR[11], on_MinTe[35], sec, off_HouR[11], off_MinTe[37], sec, c_hour, c_minute, c_second);//-5-----11:42 to 11:43
      ret118 = loadHandler( on_HouR[11], on_MinTe[40], sec, off_HouR[11], off_MinTe[42], sec, c_hour, c_minute, c_second);//-4-----11:45 to 11:46
      ret119 = loadHandler( on_HouR[11], on_MinTe[45], sec, off_HouR[11], off_MinTe[47], sec, c_hour, c_minute, c_second);//-3-----11:51 to 11:52
      ret1110 = loadHandler( on_HouR[11], on_MinTe[50], sec, off_HouR[11], off_MinTe[52], sec, c_hour, c_minute, c_second);//-2---11:54 to 11:55
      ret1111 = loadHandler( on_HouR[11], on_MinTe[55], sec, off_HouR[11], off_MinTe[57], sec, c_hour, c_minute, c_second); //-1----11:57 to 11:58

      ret120 = loadHandler( on_HouR[12], on_MinTe[0], sec, off_HouR[12], off_MinTe[2], sec, c_hour, c_minute, c_second);//0----12:1 to 12:2
      ret121 = loadHandler( on_HouR[12], on_MinTe[5], sec, off_HouR[12], off_MinTe[7], sec, c_hour, c_minute, c_second);//-11-----11:4 to 11:5
      ret122 = loadHandler( on_HouR[12], on_MinTe[10], sec, off_HouR[12], off_MinTe[12], sec, c_hour, c_minute, c_second);//-10-----11:7 to 11:8
      ret123 = loadHandler( on_HouR[12], on_MinTe[15], sec, off_HouR[12], off_MinTe[17], sec, c_hour, c_minute, c_second);//-9-----11:11 to 11:12
      ret124 = loadHandler( on_HouR[12], on_MinTe[20], sec, off_HouR[12], off_MinTe[22], sec, c_hour, c_minute, c_second);//-8-----11:16 to 11:17
      ret125 = loadHandler( on_HouR[12], on_MinTe[25], sec, off_HouR[12], off_MinTe[27], sec, c_hour, c_minute, c_second);//-7-----11:26 to 11:27
      ret126 = loadHandler( on_HouR[12], on_MinTe[30], sec, off_HouR[12], off_MinTe[32], sec, c_hour, c_minute, c_second);//-6-----11:30 to 11:31
      ret127 = loadHandler( on_HouR[12], on_MinTe[35], sec, off_HouR[12], off_MinTe[37], sec, c_hour, c_minute, c_second);//-5-----11:42 to 11:43
      ret128 = loadHandler( on_HouR[12], on_MinTe[40], sec, off_HouR[12], off_MinTe[42], sec, c_hour, c_minute, c_second);//-4-----11:45 to 11:46
      ret129 = loadHandler( on_HouR[12], on_MinTe[45], sec, off_HouR[12], off_MinTe[47], sec, c_hour, c_minute, c_second);//-3-----11:51 to 11:52
      ret1210 = loadHandler( on_HouR[12], on_MinTe[50], sec, off_HouR[12], off_MinTe[52], sec, c_hour, c_minute, c_second);//-2---11:54 to 11:55
      ret1211 = loadHandler( on_HouR[12], on_MinTe[55], sec, off_HouR[12], off_MinTe[57], sec, c_hour, c_minute, c_second); //-1----11:57 to 11:58

      ret130 = loadHandler( on_HouR[13], on_MinTe[0], sec, off_HouR[13], off_MinTe[2], sec, c_hour, c_minute, c_second);//1-----13:1 to 13:2
      ret131 = loadHandler( on_HouR[13], on_MinTe[5], sec, off_HouR[13], off_MinTe[7], sec, c_hour, c_minute, c_second);//2-----13:4 to 13:5
      ret132 = loadHandler( on_HouR[13], on_MinTe[10], sec, off_HouR[13], off_MinTe[12], sec, c_hour, c_minute, c_second);//3------13:7 to 13:8
      ret133 = loadHandler( on_HouR[13], on_MinTe[15], sec, off_HouR[13], off_MinTe[17], sec, c_hour, c_minute, c_second);//4------13:11 to 13:12
      ret134 = loadHandler( on_HouR[13], on_MinTe[20], sec, off_HouR[13], off_MinTe[22], sec, c_hour, c_minute, c_second);//5-----13:21 to 13:22
      ret135 = loadHandler( on_HouR[13], on_MinTe[25], sec, off_HouR[13], off_MinTe[27], sec, c_hour, c_minute, c_second);//6-----13:26 to 13:27
      ret136 = loadHandler( on_HouR[13], on_MinTe[30], sec, off_HouR[13], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
      ret137 = loadHandler( on_HouR[13], on_MinTe[35], sec, off_HouR[13], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
      ret138 = loadHandler( on_HouR[13], on_MinTe[40], sec, off_HouR[13], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
      ret139 = loadHandler( on_HouR[13], on_MinTe[45], sec, off_HouR[13], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
      ret1310 = loadHandler( on_HouR[13], on_MinTe[50], sec, off_HouR[13], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
      ret1311 = loadHandler( on_HouR[13], on_MinTe[55], sec, off_HouR[13], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

      ret140 = loadHandler( on_HouR[14], on_MinTe[0], sec, off_HouR[14], off_MinTe[2], sec, c_hour, c_minute, c_second);//13//----14:1 to 14:2
      ret141 = loadHandler( on_HouR[14], on_MinTe[5], sec, off_HouR[14], off_MinTe[7], sec, c_hour, c_minute, c_second);//14--------14:4 to 14:5
      ret142 = loadHandler( on_HouR[14], on_MinTe[10], sec, off_HouR[14], off_MinTe[12], sec, c_hour, c_minute, c_second);//15-------14:9 to 14:10
      ret143 = loadHandler( on_HouR[14], on_MinTe[15], sec, off_HouR[14], off_MinTe[17], sec, c_hour, c_minute, c_second);//16-----14:11 to 14:12
      ret144 = loadHandler( on_HouR[14], on_MinTe[20], sec, off_HouR[14], off_MinTe[22], sec, c_hour, c_minute, c_second);//17------14:16 to 14:17
      ret145 = loadHandler( on_HouR[14], on_MinTe[25], sec, off_HouR[14], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------14:31 to 14:32
      ret146 = loadHandler( on_HouR[14], on_MinTe[30], sec, off_HouR[14], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
      ret147 = loadHandler( on_HouR[14], on_MinTe[35], sec, off_HouR[14], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
      ret148 = loadHandler( on_HouR[14], on_MinTe[40], sec, off_HouR[14], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
      ret149 = loadHandler( on_HouR[14], on_MinTe[45], sec, off_HouR[14], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
      ret1410 = loadHandler( on_HouR[14], on_MinTe[50], sec, off_HouR[14], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
      ret1411 = loadHandler( on_HouR[14], on_MinTe[55], sec, off_HouR[14], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

      ret150 = loadHandler( on_HouR[15], on_MinTe[0], sec, off_HouR[15], off_MinTe[2], sec, c_hour, c_minute, c_second);//19------15:1 to 15:2
      ret151 = loadHandler( on_HouR[15], on_MinTe[5], sec, off_HouR[15], off_MinTe[7], sec, c_hour, c_minute, c_second);//20------15:11 to 15:12
      ret152 = loadHandler( on_HouR[15], on_MinTe[10], sec, off_HouR[15], off_MinTe[12], sec, c_hour, c_minute, c_second);//21-------15:16 to 15:17
      ret153 = loadHandler( on_HouR[15], on_MinTe[15], sec, off_HouR[15], off_MinTe[17], sec, c_hour, c_minute, c_second);//22------15:21 to 15:22
      ret154 = loadHandler( on_HouR[15], on_MinTe[20], sec, off_HouR[15], off_MinTe[22], sec, c_hour, c_minute, c_second);//23------15:31 to 15:32
      ret155 = loadHandler( on_HouR[15], on_MinTe[25], sec, off_HouR[15], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------14:31 to 14:32
      ret156 = loadHandler( on_HouR[15], on_MinTe[30], sec, off_HouR[15], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
      ret157 = loadHandler( on_HouR[15], on_MinTe[35], sec, off_HouR[15], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
      ret158 = loadHandler( on_HouR[15], on_MinTe[40], sec, off_HouR[15], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
      ret159 = loadHandler( on_HouR[15], on_MinTe[45], sec, off_HouR[15], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
      ret1510 = loadHandler( on_HouR[15], on_MinTe[50], sec, off_HouR[15], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
      ret1511 = loadHandler( on_HouR[15], on_MinTe[55], sec, off_HouR[15], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

      ret160 = loadHandler( on_HouR[16], on_MinTe[0], sec, off_HouR[16], off_MinTe[2], sec, c_hour, c_minute, c_second);//19------15:1 to 15:2
      ret161 = loadHandler( on_HouR[16], on_MinTe[5], sec, off_HouR[16], off_MinTe[12], sec, c_hour, c_minute, c_second);//20------15:11 to 15:12
      ret162 = loadHandler( on_HouR[16], on_MinTe[10], sec, off_HouR[16], off_MinTe[17], sec, c_hour, c_minute, c_second);//21-------15:16 to 15:17
      ret163 = loadHandler( on_HouR[16], on_MinTe[15], sec, off_HouR[16], off_MinTe[22], sec, c_hour, c_minute, c_second);//22------15:21 to 15:22
      ret164 = loadHandler( on_HouR[16], on_MinTe[20], sec, off_HouR[16], off_MinTe[32], sec, c_hour, c_minute, c_second);//23------15:31 to 15:32
      ret165 = loadHandler( on_HouR[16], on_MinTe[25], sec, off_HouR[16], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------14:31 to 14:32
      ret166 = loadHandler( on_HouR[16], on_MinTe[30], sec, off_HouR[16], off_MinTe[32], sec, c_hour, c_minute, c_second);//7------13:30 to 13:31
      ret167 = loadHandler( on_HouR[16], on_MinTe[35], sec, off_HouR[16], off_MinTe[37], sec, c_hour, c_minute, c_second);//8------13:36 to 13:37
      ret168 = loadHandler( on_HouR[16], on_MinTe[40], sec, off_HouR[16], off_MinTe[42], sec, c_hour, c_minute, c_second);//9----13:42 to 13:43
      ret169 = loadHandler( on_HouR[16], on_MinTe[45], sec, off_HouR[16], off_MinTe[47], sec, c_hour, c_minute, c_second);//10-----13:51 to 13:52
      ret1610 = loadHandler( on_HouR[16], on_MinTe[50], sec, off_HouR[16], off_MinTe[52], sec, c_hour, c_minute, c_second);//11-----13:54 to 13:55
      ret1611 = loadHandler( on_HouR[16], on_MinTe[55], sec, off_HouR[16], off_MinTe[57], sec, c_hour, c_minute, c_second);//12-----13:57 to 13:58

      ret170 = loadHandler( on_HouR[17], on_MinTe[0], sec, off_HouR[17], off_MinTe[2], sec, c_hour, c_minute, c_second);//23--------17:1 to 17:2
      ret171 = loadHandler( on_HouR[17], on_MinTe[5], sec, off_HouR[17], off_MinTe[7], sec, c_hour, c_minute, c_second);//22--------17:6 to 17:7
      ret172 = loadHandler( on_HouR[17], on_MinTe[10], sec, off_HouR[17], off_MinTe[12], sec, c_hour, c_minute, c_second);//21------17:11 to 17:12
      ret173 = loadHandler( on_HouR[17], on_MinTe[15], sec, off_HouR[17], off_MinTe[17], sec, c_hour, c_minute, c_second);//20------17:14 to 17:15
      ret174 = loadHandler( on_HouR[17], on_MinTe[20], sec, off_HouR[17], off_MinTe[22], sec, c_hour, c_minute, c_second);//19------17:17 to 17:18
      ret175 = loadHandler( on_HouR[17], on_MinTe[25], sec, off_HouR[17], off_MinTe[27], sec, c_hour, c_minute, c_second);//18------17:20 to 17:21
      ret176 = loadHandler( on_HouR[17], on_MinTe[30], sec, off_HouR[17], off_MinTe[32], sec, c_hour, c_minute, c_second);//17-------17:24 to 17:25
      ret177 = loadHandler( on_HouR[17], on_MinTe[35], sec, off_HouR[17], off_MinTe[37], sec, c_hour, c_minute, c_second);//16-------17:31 to 17:32
      ret178 = loadHandler( on_HouR[17], on_MinTe[40], sec, off_HouR[17], off_MinTe[42], sec, c_hour, c_minute, c_second);//15-------17:36 to 17:37
      ret179 = loadHandler( on_HouR[17], on_MinTe[45], sec, off_HouR[17], off_MinTe[47], sec, c_hour, c_minute, c_second);//14-------17:41 to 17:42
      ret1710 = loadHandler( on_HouR[17], on_MinTe[50], sec, off_HouR[17], off_MinTe[52], sec, c_hour, c_minute, c_second);//13------17:49 to 17:50
      ret1711 = loadHandler( on_HouR[17], on_MinTe[55], sec, off_HouR[17], off_MinTe[57], sec, c_hour, c_minute, c_second);//12------17:52 to 17:53

      ret180 = loadHandler( on_HouR[18], on_MinTe[0], sec, off_HouR[18], off_MinTe[2], sec, c_hour, c_minute, c_second);//11-------18:1 to 18:2
      ret181 = loadHandler( on_HouR[18], on_MinTe[5], sec, off_HouR[18], off_MinTe[7], sec, c_hour, c_minute, c_second);//10-----18:4 to 18:5
      ret182 = loadHandler( on_HouR[18], on_MinTe[10], sec, off_HouR[18], off_MinTe[12], sec, c_hour, c_minute, c_second);//9------18:7 to 18:8
      ret183 = loadHandler( on_HouR[18], on_MinTe[15], sec, off_HouR[18], off_MinTe[17], sec, c_hour, c_minute, c_second);//8------18:10 to 18:11
      ret184 = loadHandler( on_HouR[18], on_MinTe[20], sec, off_HouR[18], off_MinTe[22], sec, c_hour, c_minute, c_second);//7------18:14 to 18:15
      ret185 = loadHandler( on_HouR[18], on_MinTe[25], sec, off_HouR[18], off_MinTe[27], sec, c_hour, c_minute, c_second);//6-----18:17 to 18:18
      ret186 = loadHandler( on_HouR[18], on_MinTe[30], sec, off_HouR[18], off_MinTe[32], sec, c_hour, c_minute, c_second);//5-----18:20 to 18:21
      ret187 = loadHandler( on_HouR[18], on_MinTe[35], sec, off_HouR[18], off_MinTe[37], sec, c_hour, c_minute, c_second);//4-----18:23 to 18:24
      ret188 = loadHandler( on_HouR[18], on_MinTe[40], sec, off_HouR[18], off_MinTe[42], sec, c_hour, c_minute, c_second);//3-----18:26 to 18:27
      ret189 = loadHandler( on_HouR[18], on_MinTe[45], sec, off_HouR[18], off_MinTe[47], sec, c_hour, c_minute, c_second);//2-----18:30 to 18:31
      ret1810 = loadHandler( on_HouR[18], on_MinTe[50], sec, off_HouR[18], off_MinTe[52], sec, c_hour, c_minute, c_second);//1-----18:32 to 18:33
      ret1811 = loadHandler( on_HouR[18], on_MinTe[55], sec, off_HouR[18], off_MinTe[57], sec, c_hour, c_minute, c_second); //0----18:34 to 18:35

      ret200 = loadHandler( on_HouR[20], on_MinTe[0], sec, off_HouR[20], off_MinTe[2], sec, c_hour, c_minute, c_second);//0-------20:1 to 20:2

      ret230 = loadHandler( on_HouR[23], on_MinTe[0], sec, off_HouR[23], off_MinTe[2], sec, c_hour, c_minute, c_second);//0-----23:1 to 23:2
    }
  }
}

void setflags()
{
  //////////////////////////////////////////////////////////////////////////////6AM///////////////////////////////////////////////
  if (ret60 == 1)
  {
    setAngle(0);
  }

  else if (ret68 == 1)
  {
    setAngle(0);
  }

  else if (ret69 == 1)
  {
    setAngle(-1);
  }

  else if (ret610 == 1)
  {
    setAngle(-2);
  }

  else if (ret611 == 1)
  {
    setAngle(-3);
  }

  /////////////////////////////////////////////////////////////////////////7AM////////////////////////////////////////////////

  else if (ret70 == 1)
  {
    setAngle(-4);
  }

  else if (ret71 == 1)
  {
    setAngle(-5);
  }

  else if (ret72 == 1)
  {
    setAngle(-6);
  }

  else if (ret73 == 1)
  {
    setAngle(-7);
  }

  else if (ret74 == 1)
  {
    setAngle(-8);
  }

  else if (ret75 == 1)
  {
    setAngle(-9);
  }

  else if (ret76 == 1)
  {
    setAngle(-10);
  }

  else if (ret77 == 1)
  {
    setAngle(-11);
  }

  else if (ret78 == 1)
  {
    setAngle(-13);
  }

  else if (ret79 == 1)
  {
    setAngle(-14);
  }

  else if (ret710 == 1)
  {
    setAngle(-16);
  }

  else if (ret711 == 1)
  {
    setAngle(-17);
  }

  ////////////////////////////////////////////////////////////////////////////////////////8AM/////////////////////////////////////////////////////
  else if (ret80 == 1)
  {
    setAngle(-18);
  }

  else if (ret81 == 1)
  {
    setAngle(-19);
  }
  else if (ret82 == 1)
  {
    setAngle(-20);
  }
  else if (ret83 == 1)
  {
    setAngle(-22);
  }
  else if (ret84 == 1)
  {
    setAngle(-24);
  }
  else if (ret85 == 1)
  {
    setAngle(-26);
  }

  else if (ret86 == 1)
  {
    setAngle(-27);
  }

  else if (ret87 == 1)
  {
    setAngle(-28);
  }

  else if (ret88 == 1)
  {
    setAngle(-29);
  }

  else if (ret89 == 1)
  {
    setAngle(-30);
  }

  else if (ret810 == 1)
  {
    setAngle(-31);
  }

  else if (ret811 == 1)
  {
    setAngle(-33);
  }

  ////////////////////////////////////////////////////////////////////////////////////9AM///////////////////////////////////////////
  else if (ret90 == 1)
  {
    setAngle(-35);
  }

  else if (ret91 == 1)
  {
    setAngle(-37);
  }
  else if (ret92 == 1)
  {
    setAngle(-39);
  }

  else if (ret93 == 1)
  {
    setAngle(-40);
  }

  else if (ret94 == 1)
  {
    setAngle(-41);
  }

  else if (ret95 == 1)
  {
    setAngle(-42);
  }

  else if (ret96 == 1)
  {
    setAngle(-43);
  }

  else if (ret97 == 1)
  {
    setAngle(-44);
  }

  else if (ret98 == 1)
  {
    setAngle(-45);
  }

  else if (ret99 == 1)
  {
    setAngle(-44);
  }

  else if (ret910 == 1)
  {
    setAngle(-43);
  }

  else if (ret911 == 1)
  {
    setAngle(-42);
  }
  ////////////////////////////////////////////////////////////////////////////////10AM///////////////////////////////////////////////////////////////

  else if (ret100 == 1)
  {
    setAngle(-41);
  }

  else if (ret101 == 1)
  {
    setAngle(-40);
  }

  else if (ret102 == 1)
  {
    setAngle(-39);
  }

  else if (ret103 == 1)
  {
    setAngle(-38);
  }

  else if (ret104 == 1)
  {
    setAngle(-36);
  }

  else if (ret105 == 1)
  {
    setAngle(-35);
  }

  else if (ret106 == 1)
  {
    setAngle(-34);
  }

  else if (ret107 == 1)
  {
    setAngle(-33);
  }

  else if (ret108 == 1)
  {
    setAngle(-32);
  }

  else if (ret109 == 1)
  {
    setAngle(-31);
  }

  else if (ret1010 == 1)
  {
    setAngle(-29);
  }

  else if (ret1011 == 1)
  {
    setAngle(-28);
  }

  /////////////////////////////////////////////////////////////////11AM//////////////////////////////
  else if (ret110 == 1)
  {
    setAngle(-26);
  }
  else if (ret111 == 1)
  {
    setAngle(-25);
  }
  else if (ret112 == 1)
  {
    setAngle(-23);
  }
  else if (ret113 == 1)
  {
    setAngle(-22);
  }
  else if (ret114 == 1)
  {
    setAngle(-21);
  }
  else if (ret115 == 1)
  {
    setAngle(-20);
  }

  else if (ret116 == 1)
  {
    setAngle(-18);
  }

  else if (ret117 == 1)
  {
    setAngle(-16);
  }
  else if (ret118 == 1)
  {
    setAngle(-14);
  }

  else if (ret119 == 1)
  {
    setAngle(-13);
  }

  else if (ret1110 == 1)
  {
    setAngle(-12);
  }

  else if (ret1111 == 1)
  {
    setAngle(-10);
  }

  ///////////////////////////////////////////////////12PM//////////////////////////////////////////////////
  else if (ret120 == 1)
  {
    setAngle(-9);
  }
  else if (ret121 == 1)
  {
    setAngle(-8);
  }
  else if (ret122 == 1)
  {
    setAngle(-6);
  }
  else if (ret123 == 1)
  {
    setAngle(-5);
  }
  else if (ret124 == 1)
  {
    setAngle(-4);
  }
  else if (ret125 == 1)
  {
    setAngle(-3);
  }

  else if (ret126 == 1)
  {
    setAngle(-1);
  }

  else if (ret127 == 1)
  {
    setAngle(0);
  }

  //////////////////////////////////////////////////////////////////////////////1PM////////////////////////////////////////////////////

  else if (ret130 == 1)
  {
    setAngle(0);
  }

  else if (ret131 == 1)
  {
    setAngle(1);
  }

  else if (ret132 == 1)
  {
    setAngle(3);
  }
  else if (ret133 == 1)
  {
    setAngle(4);
  }

  else if (ret134 == 1)
  {
    setAngle(6);
  }

  else if (ret135 == 1)
  {
    setAngle(8);
  }

  else if (ret136 == 1)
  {
    setAngle(9);
  }

  else if (ret137 == 1)
  {
    setAngle(10);
  }

  else if (ret138 == 1)
  {
    setAngle(11);
  }

  else if (ret139 == 1)
  {
    setAngle(13);
  }

  else if (ret1310 == 1)
  {
    setAngle(14);
  }

  else if (ret1311 == 1)
  {
    setAngle(16);
  }

  ////////////////////////////////////////////////////////////////////2PM/////////////////////////////////////////

  else if (ret140 == 1)
  {
    setAngle(17);
  }

  else if (ret141 == 1)
  {
    setAngle(18);
  }

  else if (ret142 == 1)
  {
    setAngle(20);
  }

  else if (ret143 == 1)
  {
    setAngle(21);
  }

  else if (ret144 == 1)
  {
    setAngle(22);
  }

  else if (ret145 == 1)
  {
    setAngle(23);
  }

  else if (ret146 == 1)
  {
    setAngle(24);
  }

  else if (ret147 == 1)
  {
    setAngle(26);
  }

  else if (ret148 == 1)
  {
    setAngle(28);
  }

  else if (ret149 == 1)
  {
    setAngle(29);
  }

  else if (ret1410 == 1)
  {
    setAngle(30);
  }

  else if (ret1411 == 1)
  {
    setAngle(31);
  }
  ///////////////////////////////////////////////////////////////////////////3PM/////////////////////////////////////////////////////////////////////
  else if (ret150 == 1)
  {
    setAngle(33);
  }

  else if (ret151 == 1)
  {
    setAngle(34);
  }

  else if (ret152 == 1)
  {
    setAngle(36);
  }

  else if (ret158 == 1)
  {
    setAngle(36);
  }

  else if (ret159 == 1)
  {
    setAngle(35);
  }

  else if (ret1510 == 1)
  {
    setAngle(34);
  }

  else if (ret1511 == 1)
  {
    setAngle(33);
  }

  ///////////////////////////////////////////////////////////////////////////////5PM///////////////////////////////
  else if (ret160 == 1)
  {
    setAngle(32);
  }

  else if (ret161 == 1)
  {
    setAngle(31);
  }

  else if (ret162 == 1)
  {
    setAngle(30);
  }

  else if (ret163 == 1)
  {
    setAngle(29);
  }

  else if (ret164 == 1)
  {
    setAngle(28);
  }

  else if (ret165 == 1)
  {
    setAngle(27);
  }

  else if (ret166 == 1)
  {
    setAngle(26);
  }

  else if (ret167 == 1)
  {
    setAngle(25);
  }

  else if (ret168 == 1)
  {
    setAngle(24);
  }

  else if (ret169 == 1)
  {
    setAngle(23);
  }

  else if (ret1610 == 1)
  {
    setAngle(22);
  }

  ///////////////////////////////////////////////////////////////////////////////5PM///////////////////////////////
  else if (ret170 == 1)
  {
    setAngle(21);
  }

  else if (ret172 == 1)
  {
    setAngle(20);
  }

  else if (ret174 == 1)
  {
    setAngle(19);
  }

  else if (ret177 == 1)
  {
    setAngle(18);
  }

  else if (ret178 == 1)
  {
    setAngle(17);
  }

  else if (ret179 == 1)
  {
    setAngle(16);
  }
  else if (ret1710 == 1)
  {
    setAngle(15);
  }
  else if (ret1711 == 1)
  {
    setAngle(13);
  }

  ///////////////////////////////////////////////////////////////////6PM///////////////////////////////////////////
  else if (ret180 == 1)
  {
    setAngle(11);
  }
  else if (ret181 == 1)
  {
    setAngle(9);
  }
  else if (ret182 == 1)
  {
    setAngle(7);
  }
  else if (ret183 == 1)
  {
    setAngle(4);
  }
  else if (ret184 == 1)
  {
    setAngle(2);
  }
  else if (ret185 == 1)
  {
    setAngle(0);
  }

  else if (ret1811 == 1)
  {
    setAngle(0);
  }

  ////////////////////////////////////////////////////////////////////////////11PM////////////////////////////

  else if (ret230 == 1)
  {
    setAngle(0);
  }
  /////////////////////////////////////////////////////else////////////////////
  else
  {
    stop_Mode();
  }
}

void setAngle(int angle1)
{
  if (Angle_Degree < angle1)
  {
    clockwise_Mode();
  }
  else if (Angle_Degree > angle1)
  {
    anti_clockwise_Mode();
  }
  else if ((Angle_Degree == angle1))
  {
    stop_Mode();
  }
}

///////////////////////////////////////////////////////////////////////////////////////////////
void get_Angle()
{
  long angle_average = 0;
  for (int i = 0; i < 250; i++)
  {
    mpu6050.update();
    //angle_average += 90 * (accel.getCalculatedX());
    angle_average += (int)(mpu6050.getAccAngleX());
  }
  Angle_Degree = (angle_average / 250);
  angle_average = 0;
}

void get_time()
{
  tmElements_t tm;
  (RTC.read(tm));
  c_hour = tm.Hour;
  c_minute = tm.Minute;
  c_second = tm.Second;
}

void clockwise_Mode()
{
  // if (MD == 1)
  // {
  motor.setSpeed(-255);
  //
  // currentTime = millis();
  // if ((unsigned long)(currentTime - previousTime) >= interval)
  // {
  // if (Angle_Degree != angle)
  // {
  // MD = 0;
  // }
  // else
  // MD = 1;
  // previousTime = currentTime;
  // }
  // }
}

void anti_clockwise_Mode()
{
  motor.setSpeed(255);
}

void stop_Mode()
{
  motor.setSpeed(0);
}

byte loadHandler(byte onTimeHr, byte onTimeMin, byte onTimeSec, byte offTimeHr, byte offTimeMin, byte offTimeSec, byte rtcTimeHr, byte rtcTimeMin, byte rtcTimeSec)
{
  userTime_t in1 = {onTimeHr, onTimeMin, onTimeSec}, in2 = {offTimeHr, offTimeMin, offTimeSec}, rtc_hr = {rtcTimeHr, rtcTimeMin, rtcTimeSec}, a = {}, b = {};

  if (checkLessThanOrEqual(in1, in2))
  {
    onOrOffFlag = ON;
    memcpy(&a, &in1, sizeof(userTime_t));
    memcpy(&b, &in2, sizeof(userTime_t));
  }
  else
  {
    onOrOffFlag = OFF;
    memcpy(&a, &in2, sizeof(userTime_t));
    memcpy(&b, &in1, sizeof(userTime_t));
  }

  if ((checkLessThanOrEqual(a, rtc_hr)) && (checkLessThanOrEqual(rtc_hr, b)))
  {
    if (onOrOffFlag == ON)
    {
      return HIGH;
    }
    else
    {
      return LOW;
    }
  }
  else
  {
    if (onOrOffFlag == ON)
    {
      return LOW;
    }
    else
    {
      return HIGH;
    }
  }
}

unsigned char checkLessThanOrEqual(userTime_t a, userTime_t b)
{
  if (a.temp_hour < b.temp_hour)
    return true;
  else
  {
    if ((a.temp_hour == b.temp_hour) && (a.temp_minute < b.temp_minute))
    {
      return true;
    }
    else
    {
      if (a.temp_hour > b.temp_hour)
        return false;
      else
      {
        if ((a.temp_minute == b.temp_minute) && (a.temp_second < b.temp_second))
        {
          return true;
        }
        else
        {
          if (a.temp_minute > b.temp_minute)
            return false;
          else
          {
            if (a.temp_second == b.temp_second)
            {
              return true;
            }
            else
            {
              return false;
            }
          }
        }
      }
    }
  }
}

void bluetooth_part()
{
  readdata = digitalRead(Bluetooth_stats);
  if (readdata == 1)
  {
    if (Bluetooth_connect_flag == 1)
    {
      Bluetooth.println("BT-CNCTD");
      tmElements_t tm;
      (RTC.read(tm));
      Bluetooth.print("Time = ");
      Bluetooth.print(tm.Hour);
      Bluetooth.print(": ");
      Bluetooth.print(tm.Minute);
      Bluetooth.print(": ");
      Bluetooth.println(tm.Second);
      Bluetooth.print("Ang = ");
      Bluetooth.println(Angle_Degree);
      Bluetooth_connect_flag = 0;
    }
  }
  else if ((readdata == 0) && (Bluetooth_connect_flag == 0))
  {
    Bluetooth_connect_flag = 1;
  }
  if (Bluetooth.available() > 0)
  {
    if (Bluetooth.find('*'))
    {
      Blue_thmillis_strt = millis();
      string = "";
      while (1)
      {
        Blue_thmillis_stop = millis();
        char c = Bluetooth.read();
        if ((c == '#') || ((Blue_thmillis_stop - Blue_thmillis_strt) > 2000))break;
        string += c;
        delay(10);
      }
    }
  }
  char n[1] = {};

  String m = string.substring(0, 1);
  m.toCharArray(n, 2);
  switch (n[0])
  {
    case 'S':
      tmElements_t tm;
      Time[0] = string.substring(1, 3);
      Time[1] = string.substring(4, 6);
      Time[2] = string.substring(7, 9);
      Time[3] = string.substring(10, 12);
      Time[4] = string.substring(13, 15);
      tm.Hour = Time[0].toInt();
      tm.Minute = Time[1].toInt();
      tm.Second = 00;
      tm.Day = Time[2].toInt();
      tm.Month = Time[3].toInt();
      Year = Time[4].toInt() - 78;
      tm.Year = CalendarYrToTm(Year);;
      RTC.write(tm);
      Bluetooth.println("TD: set to");
      Bluetooth.print("Time = ");
      Bluetooth.print(Time[0]);
      Bluetooth.print(": ");
      Bluetooth.print(Time[1]);
      Bluetooth.print(": ");
      Bluetooth.println("00");
      Bluetooth.print("Date = ");
      Bluetooth.print(Time[2]);
      Bluetooth.print(" / ");
      Bluetooth.print(Time[3]);
      Bluetooth.print(" / ");
      Bluetooth.println(Time[4]);
      Time[0] = "";
      Time[1] = "";
      Time[2] = "";
      Time[3] = "";
      Time[4] = "";
      string = "";
      break;
    case 'R':
      (RTC.read(tm));
      Bluetooth.print("Time = ");
      Bluetooth.print(tm.Hour);
      Bluetooth.print(": ");
      Bluetooth.print(tm.Minute);
      Bluetooth.print(": ");
      Bluetooth.println(tm.Second);
      Bluetooth.print("Angle = ");
      Bluetooth.println(Angle_Degree);
      string = "";
      break;
    case '1':
      Bluetooth.print("CLK-WISE");
      disableAutoFlag = 1;
      //clockwise_Mode();
      string = "";
      break;
    case 'T':
      Bluetooth.print("ANTI-CLK");
      disableAutoFlag = 2;
      //anti_clockwise_Mode();
      string = "";
      break;
    case '0':
      Bluetooth.print("STOPPED");
      disableAutoFlag = 3;
      stop_Mode();
      string = "";
      break;
  }
}

I don't think I did any damage, but I am uncaffienated, so.

After 5 minutes: Caffeine isn't going to help. :expressionless:

This looks like it was coded in Esperantolol.

a7

Esperantolol
I like it with or without the LOL ,

Are you monitoring your Arduino for overheating? Sounds like it's getting a good bit of heat and direct sunlight.

  if (Bluetooth.available() > 0)
  {
    if (Bluetooth.find('*'))
    {
      Blue_thmillis_strt = millis();
      string = "";
      while (1)
      {
        Blue_thmillis_stop = millis();
        char c = Bluetooth.read();
        if ((c == '#') || ((Blue_thmillis_stop - Blue_thmillis_strt) > 2000))break;
        string += c;
        delay(10);
      }
    }
  }

I question how long string (which is a String) will become since there is no check to make sure the buffer has characters available before each read(). The delay of 10mS does help by only allowing time for approximately 200 characters.

@pradeepdeepu

Please post the code you are running and describe just how and when it hangs.

Use the </> tool in the window you write in to post, or use the IDE "Copy for Forum" from the Edit menu.

  so your code doesn't get damaged

  so your code can be copied

  it should look like this.


Use the "autoformat" tool in the IDE to fix up your formatting a bit before you paste it here, which ever way you choose.

I tried, but your code was already damaged by the way you pasted it into your message directly.

a7