Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:20 19 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MM code

Author Message
Chrisk

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 118
Posted: 07:39pm 16 Feb 2016
Copy link to clipboard 
Print this post

Hi Guys

I wish to NOT carry out a particular function (prevent a fan from coming ON) between the hours of 6pm and 8am the next day.
I have no idea where to start.
Can someone help with the code for this.
I am using a CMM with Ver4.5


Thanks

Chris K
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 08:48pm 16 Feb 2016
Copy link to clipboard 
Print this post

I don't have a CMM running to test with at the moment but this should work
controlpin = 6 ' choose a suitable IO pin
setpin controlpin, dout

settick 1000, checktime ' check the time every second


do
' do other things
loop
end

sub checktime
now$ = time$
print now$
hour$=mid$(now$,1,2)
if hour$ >="18" or hour$ <"08" then ' time is after 6pm or before 8am
fancontrol = 0
else
fancontrol = 1
end if
pin(controlpin) = fancontrol
print fancontrol
end sub


If you want to do other things with the fan control, you can use the variable 'fancontrol' to test if it is OK to run the fan.

It is OK to compare the time as a string in this case and you can also add minutes to the tests for finer control.

Jim
VK7JH
MMedit   MMBasic Help
 
Chrisk

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 118
Posted: 09:00pm 16 Feb 2016
Copy link to clipboard 
Print this post

Thanks for the quick reply Jim.

It is the sub checktime that I needed.

Chris K
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024