displaying parameter

Dear all

i am using arduino UNo board with DS1307. I have 6 switches 2 single digit 7 segment display and 4 stacked 7 segment display.

Switch1: To select Relay operation 1 Single digit display from 1-8 . whenever Relay switch is pressed Display shows 0-8 segment

Switch2: To select combination 1 Single digit display from 1-8 . whenever comb switch is pressed Display shows 0-8 segment. That means user can program Relay 1 to 1-8 progrm

Switch 3 to choose on time and off time

switch 5: Select switch to decrements the display parameter

switch 6 : Select switch to increment the display parameter

switch 4: to change Display paramter as Hour/Min

i have used serial in parallel out concept to drive display its working well.

I have I2c device DS1307 and 24LC08 . I need some suggestion to improvise code.

i have function name Process_advance_SW() & Process_select_SW() Here where i am increment and decrements values of Ontime and off time.

since i have 1 relay with 8 combination . similarly 8 relay with 8 combination totally i have 64 program where i should save Ontime and off time hour

kindly suggest me some function where i could minimise writing of these value .

I would like to know when we should write/how should we write into external EEPROM in this scenarios.

similarly when it come to run mode it should read only once.

Ard_code.txt (22 KB)

with this post you give your potential helpers amost the maximum work they could have:
Analysing your complete code to understand what your code does.

You should take away as much work as possible from your potential helpers through providing as much information as you can. I simply don't understand your questions

since i have 1 relay with 8 combination . similarly 8 relay with 8 combination totally i have 64 program where i should save Ontime and off time hour

kindly suggest me some function where i could minimise writing of these value .

I would like to know when we should write/how should we write into external EEPROM in this scenarios.

similarly when it come to run mode it should read only once.

So answering in a similar briefly manner would be "use an EEPROM-library of your choice"

  • which of course does not help very much.

I guess english is not your native language. If you have troubles to write in english
Have you looked into the sub-forums if your native-language is listed as sub-forum?

best regards Stefan
any newbee can apply the most professional habit from the first line of code they write on their own:
add only ONE thing at a time. Test/debug that ONE thing until that ONE thing works reliable - repeat.
The sad thing is: only the REAL professionals write code this way.

HI. My English poor ,not expert like you.

I am not asking to write whole code , I just asked how can do it .
I have these 2 function whenever advance key pressed process advance will be triggered and when select button pressed Process_select_SW() will be processed

advance key is to increment the values and select key to decrement the values. Currently below code

if i have selected Rly=1 comb=1 on_off=0 or 1 hour_bit=0/1 in these combination it will write to Individual hour_ontime and hour_offtime bits. and its working well.

since there 8 relays 8 combinations
meaning Rly=1 comb=1-8 on_off=0 or 1 hour_bit=0/1 these condition keep repeating for 8relay 8 combinations .how can minimize the function .

If i repeat below condition 64 times with changing Relay==1 and comb==2 & so on i could able to get . But instead of that is there any way i could reduce these instructions.

void Process_advance_SW() {
  unsigned char Temp = 0;
  if (pgm_run == 1) {
    if (SELECTPRESS == 0) {
      if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 1)) {
        Hour_ON1++;
        if (Hour_ON1 > 24) {
          Hour_ON1 = 0;
        }

        LEDBuffer_1[1] = DISPTABLE[Hour_ON1 / 10];
        LEDBuffer_1[0] = DISPTABLE[Hour_ON1 % 10];

      } else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 0)) {
        Min_ON1++;
        if (Min_ON1 > 59) {
          Min_ON1 = 0;
        }
        LEDBuffer_1[1] = DISPTABLE[Min_ON1 / 10];
        LEDBuffer_1[0] = DISPTABLE[Min_ON1 % 10];

      } else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 1)) {
        Hour_OFF1++;
        if (Hour_OFF1 > 24) {
          Hour_OFF1 = 0;
        }
        LEDBuffer_1[1] = DISPTABLE[Hour_OFF1 / 10];
        LEDBuffer_1[0] = DISPTABLE[Hour_OFF1 % 10];

      }
      if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 0)) {
        MIN_OFF1++;
        if (MIN_OFF1 > 59) {
          MIN_OFF1 = 0;
        }
        LEDBuffer_1[1] = DISPTABLE[MIN_OFF1 / 10];
        LEDBuffer_1[0] = DISPTABLE[MIN_OFF1 % 10];
      }

      DATE_TIME_SET_ADD();
    }
  }
}

void Process_select_SW() {
  if (pgm_run == 1) {
    if (SELECTPRESS == 0) {
      if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 1)) {
        Hour_ON1--;
        if (Hour_ON1 < 1) {
          Hour_ON1 = 24;
        }
        LEDBuffer_1[1] = DISPTABLE[Hour_ON1 / 10];
        LEDBuffer_1[0] = DISPTABLE[Hour_ON1 % 10];

      } else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 0)) {
        Min_ON1--;
        if (Min_ON1 < 1) {
          Min_ON1 = 59;
        }
        LEDBuffer_1[1] = DISPTABLE[Min_ON1 / 10];
        LEDBuffer_1[0] = DISPTABLE[Min_ON1 % 10];

      } else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 1)) {
        Hour_OFF1--;
        if (Hour_OFF1 < 1) {
          Hour_OFF1 = 24;
        }
        LEDBuffer_1[1] = DISPTABLE[Hour_OFF1 / 10];
        LEDBuffer_1[0] = DISPTABLE[Hour_OFF1 % 10];

      }
      if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 0)) {
        MIN_OFF1--;
        if (MIN_OFF1 < 1) {
          MIN_OFF1 = 59;
        }
        LEDBuffer_1[1] = DISPTABLE[MIN_OFF1 / 10];
        LEDBuffer_1[0] = DISPTABLE[MIN_OFF1 % 10];
      }

      DATE_TIME_SET_SUB();
    }

  }

}

Can use function like this

unsigned char  Array[10] = {0};
#define LED 13
void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);

}

void loop() {
  Serial.println("Welcome");
  digitalWrite(LED, 1);
  delay(1000);
  digitalWrite(LED, 0);
  delay(1000);
  Array[0] = Array[0] + 1;
  Serial.print("Array element");
  Serial.println(Array[0]);
  Serial.println(",..............................................");

}

more support from me only if you answer these questions:
which country do you live in?
what is your motherlanguage?

don't understand your english.
make drawings that explains EVERYTHING with pictures NO WORDS just DRAWINGS

Here i Have attached image for reference.

I have attached how my front display and switches . I would like to minimize function for Process_select and Process_advance.

In fig i shown how many key are present and what it will do operation. if u could understand let me know.

RLY=1 selected means we can program from 1 to 8 by selecting 8 combination.
comb- display which combination we are programming. which shows from 0-8
next come on_off , if led high means on time if off means off time.
next switch allow user to set HR Or MIn
means display showing HO:00 timing. by pressing select you can decrement value & by pressing advance key we can increment value.

on pressing advance key HO:00 increment from 0-24 similarly select key decrement this value.

Now in all prospect it working. the code is in thread 1 is for 1 combination. like that relay1 has 8 combination. my question is how can simplify??

answer my two questions first:
what is your motherlanguage?
What country do you live in?

  if (Comb_No == 1)
  {
    i = 1;
  } else if (Comb_No == 2)
  {
    i = 2;
  } else if (Comb_No == 3)
  {
    i = 3;
  }
  else if (Comb_No == 4)
  {
    i = 4;
  }

  else if (Comb_No == 5)
  {
    i = 5;
  }

  else if (Comb_No == 6)
  {
    i = 6;
  }

Err…

Are you getting paid by the LOC?

मेरे दो सवालों को पहले मारो
तुम्हारी मातृभाषा क्या है
आप किस देश के रहने वाले हैं
mere do savaalon ko pahale maaro
tumhaaree maatrbhaasha kya hai
aap kis desh ke rahane vaale hain

প্রথমে আমার দুটি প্রশ্নকে বীট ওয়ার্ড করুন
তোমার মাতৃভাষা কি
তুমি কোন দেশে বাস করো
Prathamē āmāra duṭi praśnakē bīṭa ōẏārḍa karuna
tōmāra mātr̥bhāṣā ki
tumi kōna dēśē bāsa karō

پہلے میرے دو سوالات کی مار دو
تمہاری مادری زبان کیا ہے
آپ کس ملک میں رہتے ہیں؟

முதலில் எனது இரண்டு கேள்விகளைக் குறிக்கவும்
உன்னுடைய தாய் மொழி எது
நீங்கள் எந்த நாட்டில் வாழ்கிறீர்கள்
Mutalil eṉatu iraṇṭu kēḷvikaḷaik kuṟikkavum
uṉṉuṭaiya tāy moḻi etu
nīṅkaḷ enta nāṭṭil vāḻkiṟīrkaḷ

પહેલા મારા બે પ્રશ્નોને બીટવર્ડ કરો
તમારી માતૃભાષા શું છે?
તમે કયા દેશમાં રહો છો
Pahēlā mārā bē praśnōnē bīṭavarḍa karō
tamārī mātr̥bhāṣā śuṁ chē?
Tamē kayā dēśamāṁ rahō chō

ಮೊದಲು ನನ್ನ ಎರಡು ಪ್ರಶ್ನೆಗಳನ್ನು ಬೀಟ್ ವರ್ಡ್ ಮಾಡಿ
ನಿಮ್ಮ ಮಾತೃಭಾಷೆ ಏನು
ನೀವು ಯಾವ ದೇಶದಲ್ಲಿ ವಾಸಿಸುತ್ತೀರಿ
Modalu nanna eraḍu praśnegaḷannu bīṭ varḍ māḍi
nim'ma mātr̥bhāṣe ēnu
nīvu yāva dēśadalli vāsisuttīri

ആദ്യം എന്റെ രണ്ട് ചോദ്യങ്ങൾക്ക് ഉത്തരം നൽകുക
നിങ്ങളുടെ മാതൃ ഭാഷ എന്താണ്
ഏത് രാജ്യത്താണ് നിങ്ങൾ താമസിക്കുന്നത്?
ādyaṁ enṟe raṇṭ cēādyaṅṅaḷkk uttaraṁ nalkuka
niṅṅaḷuṭe mātr̥ bhāṣa entāṇ
ēt rājyattāṇ niṅṅaḷ tāmasikkunnat?

प्रथम माझे दोन प्रश्न विजय
तुमची मातृभाषा काय आहे
आपण कोणत्या देशात राहता?
Prathama mājhē dōna praśna vijaya
tumacī mātr̥bhāṣā kāya āhē
āpaṇa kōṇatyā dēśāta rāhatā?

ପ୍ରଥମେ ମୋର ଦୁଇଟି ପ୍ରଶ୍ନ ବିଟୱାର୍ଡ |
ତୁମର ମାତୃଭାଷା କ’ଣ?
ଆପଣ କେଉଁ ଦେଶରେ ରୁହନ୍ତି |

మొదట నా రెండు ప్రశ్నలను బీట్వర్డ్ చేయండి
మీ మాతృభాష ఏమిటి
మీరు ఏ దేశంలో నివసిస్తున్నారు
Modaṭa nā reṇḍu praśnalanu bīṭvarḍ cēyaṇḍi
mī mātr̥bhāṣa ēmiṭi
mīru ē dēśanlō nivasistunnāru

ਪਹਿਲਾਂ ਮੇਰੇ ਦੋ ਪ੍ਰਸ਼ਨਾਂ ਨੂੰ ਕੁੱਟੋ
ਤੁਹਾਡੀ ਮਾਂ-ਬੋਲੀ ਕੀ ਹੈ?
ਤੁਸੀਂ ਕਿਸ ਦੇਸ਼ ਵਿੱਚ ਰਹਿੰਦੇ ਹੋ
Pahilāṁ mērē dō praśanāṁ nū kuṭō
tuhāḍī māṁ-bōlī kī hai?
Tusīṁ kisa dēśa vica rahidē hō

پهرين منهنجي ٻن سوالن کي ٽوٽايو
توهان جي مادري ٻولي ڇا آهي؟
توهان ڪهڙي ملڪ ۾ رهندا آهيو