Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:44 20 Apr 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 : help needed with simple program

Author Message
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 05:31am 13 Jul 2011
Copy link to clipboard 
Print this post

what i need to do is set pin`s 1 2 3 high for 15 seconds one at a time then run it in a loopEdited by sparkey 2011-07-14
technicians do it with least resistance
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 06:50am 13 Jul 2011
Copy link to clipboard 
Print this post

A slight change to the program so it shows the current state on the terminal....

here is a simple snippet of code to do as requested:


10 status = 1 'intialise the status variable
20 pin(1) = 1 'set pin 1 to be high intially
30 pin(2) = 0 'set pin 2 to be low intially
40 pin(3) = 0 'set pin 3 to be low intially
50 setpin 1,8 'set pin 1 for digital output
60 setpin 2,8 'set pin 2 for digital output
70 setpin 3,8 'set pin 3 for digital output
80 cls:print "Enter y or CNTL-C to stop the program "
85 print:print "State: "; status;
90 settick 15000, 1000 'set tick interrupt for every 15 seconds
98 'loop here forever (or until CNTL-C or 'y'
99 ' entered on the keyboard/USB terminal)
100 do
110 c$ = inkey$
120 if c$ = "y" or c$ = "Y" then 200
130 loop
200 end
998 'settick interrupt routine
999 ' update the pin values and the status variable
1000 if status = 1 then
1010 pin(1) = 0 : pin(2) = 1 : status = 2
1020 locate 42,24:print status;
1030 elseif status = 2 then
1040 pin(2) = 0 : pin(3) = 1 : status = 3
1050 locate 42,24:print status;
1060 elseif status = 3 then
1070 pin(3) = 0 : pin(1) = 1 : status = 1
1080 locate 42,24:print status;
1090 endif
1100 ireturn 'return from the settick interrupt routine


regards

GerardEdited by seco61 2011-07-14

Regards

Gerard (vk3cg/vk3grs)
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 10:26am 13 Jul 2011
Copy link to clipboard 
Print this post

thanks gerard thats great but there is a couple of problems the program actully ends and also when pin one is on ineed pis 2 and three off and so when pin 2 is on i need pins one and tree off and when pin 3 is on then i need pin one and two off and so it does look like you have done this in the programme just maybe there is something missing for it to runn repeatidly i have tried implementing a goto statement but not shure if this is working i seem only to get pin one to switch then after that the programme comes to a end ...regards and thank you for taking the time to write this for me muych app....
technicians do it with least resistance
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 12:06pm 13 Jul 2011
Copy link to clipboard 
Print this post

Hi.

It runs forever on my Maximite unless I type "y" or "Y" or hit Cntl-C.

The pins are defintely set up so that only one of the three pins is on at one time.

If you have copied the code exactly as above and it is stopping, can you add the following line (to reduce the amount of output):


105 pause 60000


then issue the TRON command and then run the program again and post the output.

Regards

Gerard

Regards

Gerard (vk3cg/vk3grs)
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 12:15pm 13 Jul 2011
Copy link to clipboard 
Print this post

I have cut and pasted the above program into the maximite and have had it running for about 2 hours so far with no problems. Maybe a typo when entering the program!
Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 03:58pm 13 Jul 2011
Copy link to clipboard 
Print this post

thats a different programme to the one i first copy`d and yes thank you guys i just spent five hours trying to get the first one to work but this one does thanks all...regards sparkey end of matter working

technicians do it with least resistance
 
Print this page


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

© JAQ Software 2024