Picaxe small project request

Thread Starter

happysoul

Joined Sep 9, 2014
28
Hi guys and gals
i was wondering if someone could give me the picaxe coding for a small project .On power up i need to have one output pin pulse 6 times( or variable 8 max), say once a second and then stop till it is powered up next time.
thanks ahead
Happysoul.
 

elec_mech

Joined Nov 12, 2008
1,500
Not to be dismissive, but why not post this on the PICAXE forum: http://www.picaxeforum.co.uk/forum.php
What, and let them have all the fun?

Here you go:
Code:
#picaxe 08m2                       ' Define PICAXE 08M2
#no_data                           ' Ignore EEPROM data - loads program faster

'========================================================================

Initialize:                        ' Initialize Routine - initialize pins and set up variables
    LET dirsC = %00000010          ' Make pin C.1 a output; rest as inputs
    LET pinsC = %00000000          ' Turn off all outputs on port C
    SYMBOL i = b0                  ' Data byte variable used with FOR loop
    LET i = 0                      ' Set i equal to 0
    SYMBOL pulse_num = b1          ' Data byte variable used to set number of cycles or loops
    LET pulse_num = 6              ' Set pulse_num equal to 6
    SYMBOL pulse_high = b2         ' Data byte variable used to set pulse high time
    LET pulse_high = 500           ' Set pulse_num equal to 500 (milliseconds)  
    SYMBOL pulse_low = b3          ' Data byte variable used to set pulse low time
    LET pulse_high = 500           ' Set pulse_num equal to 500 (milliseconds)

Main:                              ' Main Routine

FOR i = 1 to pulse_num             ' Perform following pulse_num of times
    HIGH C.1                       ' Make output on C.1 high
    PAUSE pulse_high               ' Wait for pulse_high time
    LOW C.1                        ' Make output on C.1 low
    PAUSE pulse_high               ' Wait for pulse_low time
NEXT                               ' Repeat

END                                ' End program
You can change the pulse high and low times to suit your needs as well as the number of loops. As currently written, the pulse will be high for half a second then low for half a second or to put another way 1 Hz with a 50% duty cycle.
 

Thread Starter

happysoul

Joined Sep 9, 2014
28
What, and let them have all the fun?

Here you go:
Code:
#picaxe 08m2                       ' Define PICAXE 08M2
#no_data                           ' Ignore EEPROM data - loads program faster

'========================================================================

Initialize:                        ' Initialize Routine - initialize pins and set up variables
    LET dirsC = %00000010          ' Make pin C.1 a output; rest as inputs
    LET pinsC = %00000000          ' Turn off all outputs on port C
    SYMBOL i = b0                  ' Data byte variable used with FOR loop
    LET i = 0                      ' Set i equal to 0
    SYMBOL pulse_num = b1          ' Data byte variable used to set number of cycles or loops
    LET pulse_num = 6              ' Set pulse_num equal to 6
    SYMBOL pulse_high = b2         ' Data byte variable used to set pulse high time
    LET pulse_high = 500           ' Set pulse_num equal to 500 (milliseconds) 
    SYMBOL pulse_low = b3          ' Data byte variable used to set pulse low time
    LET pulse_high = 500           ' Set pulse_num equal to 500 (milliseconds)

Main:                              ' Main Routine

FOR i = 1 to pulse_num             ' Perform following pulse_num of times
    HIGH C.1                       ' Make output on C.1 high
    PAUSE pulse_high               ' Wait for pulse_high time
    LOW C.1                        ' Make output on C.1 low
    PAUSE pulse_high               ' Wait for pulse_low time
NEXT                               ' Repeat

END                                ' End program
You can change the pulse high and low times to suit your needs as well as the number of loops. As currently written, the pulse will be high for half a second then low for half a second or to put another way 1 Hz with a 50% duty cycle.
 
Top