Go Down

Topic: programming help (Read 987 times) previous topic - next topic

AMPS-N

Dear all.

I wanna write simple code for arduino board.

Assume that i have real time clock. I wanna min value of time and recorded in variable once @ time. I could able to reset the  variable after 10 min . can some help me how can we achieve this

pseudo code:

previous value<--preset value
                    check ( present value-previous value== 10 min)
                             if yes
                                 reset preset value and print hello


                              if not
                                      print welcome

previous value should recorded only once
AMPS

UKHeliBob

Have you got any real code to which this requirement is to be added ?

Can you explain more clearly what you want to do ?
What is to be recorded and when ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

AMPS-N

#2
Feb 07, 2013, 10:02 am Last Edit: Feb 07, 2013, 10:06 am by AMPS-N Reason: 1
i wanna simple code in c  where i can expect result as above psedo code


assume i have RTC which give me hour/min/sec

@ first i wanna record present min,
then after 10 min i wanna print "hello" and update the present value

this step has executed every 10 min


AMPS

Groove

The phrase you're struggling with is "want to".
Per Arduino ad Astra

saptarshi14datta

if i understand the problem correctly here is a possible solution

void loop(){
float hour = //your current time from sensor
float min = //
float sec = //

for (i=0; i < 10, i++){
delay(60000) //here you have to ensure that the arduino can delay for 1 min, iif not you have to create nested loops
}

Serial.print("Hello");// whatever else you want to type

}//end of void loop

AMPS-N

In this below program it gives delay 1 min .

what i wanna do is keep updating previous value with new newly recorded value of time.

Assume i have time 10h10m10s
assume previous value has 00m @ start
now hence 10 min passed it will update previous value to 10 from 0 and current value keep incrementing..

when(current value-previous value is 10 min )
update previous to current and print message
else incrementing current value

AMPS

AWOL

Code: [Select]
float hour = //
You have fractional hours?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

AMPS-N

no . it doesnot matter .


I have integer value for assigning the min and hour
AMPS

AMPS-N

Dear all,

Can some one share me the simple code where i can update the current value to previous value.

assume i have RTC , Where i wanna record time for every 10 min  with current one. reason i wanna do that  for every 10 min i wanna actuate motor.
pseudo code :

previous time = current time:
if ( current time-previous time>=10 min)
          print "hello" and update previous time == current time and turn  on motor
else
print "welcome" and keep counting current time and turn off motor

i need simple c code for above .

i am using arduino board uno board.i don't want use  delay timer .since some code might get affected

AMPS

PaulS

Quote
previous time = current time:
if ( current time-previous time>=10 min)
          print "hello" and update previous time == current time and turn  on motor

If you set previous time to current time, how the hell is the difference ever going to be greater than 10 minutes?

Post some REAL code - in this thread. DO NOT START ANOTHER ONE.

How are you getting the time? Current, real, imaginary, or phantom?

AMPS-N

Dear all.

How can simple  c code for arduino UNO board to update the values every 10 min

assume i have motor and rtc

pseudo code i am looking for:

previous time =0;
current time ;
if (current time -previous time ==10 min)
print hello, update previous time to current time and turn on the motor
else
print welcome , current value keep incrementing till 10 min reached and turn off motor

i don't want use delay function here . Using normal counter or variable how can achieve above code.previous time recorded one @ time and get updated after it complete 10 min.

i hope someone help me out



AMPS

AMPS-N

#11
Feb 07, 2013, 02:09 pm Last Edit: Feb 07, 2013, 02:13 pm by AMPS-N Reason: 1
in below code i am saying that,

previous value get update current value only first time execution
after that difference should get varied .
after completion of 10 min . previous value get updated with the current .motor should start


i have mentioned that i have real time clock. where i am getting time




AMPS

PaulS

Reported to moderators. This spamming has got to stop.

You need to do SOMETHING on your own.

AWOL

#13
Feb 07, 2013, 02:22 pm Last Edit: Feb 07, 2013, 02:29 pm by AWOL Reason: 1
Topics merged.

OP - don't repeat this.

Quote
in below code i am saying that,

There is no code below (unless your monitor is upside-down)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

HazardsMind

There are PLENTY of RTC code in either here or project guidence, that do something after a certain time has passed. Most, if not ALL have examples. Find them, read them, learn from them, and write your own. Come back when you have an actual code that compiles or at least has some errors that make sense based on what you wrote.

No code, no help.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Go Up