Another Programming Beginner 1st Attempt

cpman46

New Member
Hi
I am trying to use a Axe012X2 to monitor a number of inputs and two push-buttons to light one or more LEDs on a gantry according to the state of the inputs and which button was pressed.

After the initial start up when all outputs are switched on and off three times to prove all LEDs are working the micro needs to continually monitor the state of the 6 inputs and the 2 push-button inputs. When a push-button is activated (input pulled low) the current state of the 6 inputs needs to be written to the corresponding outputs. Once done the program needs to monitor the 6 inputs and two buttons once more and act upon the next button press and continue ad infinitum.

I attach my first attempt program which seems to work (simulated mode) but would be grateful for any constructive comments.
Many thanks
Mike
View attachment NJ FYG BRUP Dev1.bas :)
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

You code generally looks okay but at least one issue -

symbol delay = b2
delay = 1000

You cannot store a value greater than 255 in a 'b' byte variable. You may be better off defining 'delay' as a numeric constant rather than a variable if it never changes -

symbol delay = 1000

As to the rest of the code it seems fine for a first attempt. It might be worth explaining in greater detail exactly what pushing BRS or UPS buttons should do, exactly how the outputs should be set under all circumstances, if you need help with that.

Note that your "if BRS = 1 or UPS = 1 then" will have to be 0's not 1's if you have active low hardware. Active low can sometimes be a pain to simulate but you can use the following to make it easier ...

Code:
#IfDef SIMULATING
  if BRS = 1 or UPS = 1 then
#Else
  if BRS = 0 or UPS = 0 then
#EndIf
 

BESQUEUT

Senior Member
Note that your "if BRS = 1 or UPS = 1 then" will have to be 0's not 1's if you have active low hardware. Active low can sometimes be a pain to simulate but you can use the following to make it easier ...

Code:
#IfDef SIMULATING
  if BRS = 1 or UPS = 1 then
#Else
  if BRS = 0 or UPS = 0 then
#EndIf
You can also have :
symbol On=1 ' or =0 as needed
symbol Off=1-On


so you can write :
if BRS = On or UPS = On Then
 
Last edited:
Top