A little assistance required

ternent

New Member
Hi Guys,

Its been just short of 10 year since i last used and programmed a pic chip and i seem to be having some issues.

I am using PICAXE Editor 6 with an 08M chip on a Revolution Education board. The idea is to use 1 input and 2 outputs.

A push to make button to hold on the two outputs, one to send a signal to a relay board to switch on a 12V LED strip, and the other to power a single LED.

I have the button hooked up to input 1 (not 0) and the relay switch to output 0 and the single let to output 1

Where am i going wrong with programming?

Thanks

Code:
loop1: if pin1 = 1 then goto loop2
	 goto loop1:
	
loop2: high 0
	 high 1
	 wait 10
	 goto loop3

loop3: if pin1 = 1 then goto loop4
	 goto loop3
	
loop4: low 0
	 low 1
	 goto loop1
 
Last edited:

nick12ab

Senior Member
You have the push button connected to pin1... but you're using the high command to make that pin stay high after the pin has initially gone high.
 

Technical

Technical Support
Staff member
You can't have pin 1 as both an input (if pin1...) and as an output (high 1). So there is a wiring confusion somewhere with how you have connected your i/o
 

ternent

New Member
Sorry I'm going by whats written on the board. the board has 2 inputs and 4 outputs.

by what you's have said, does that mean i am using pin 2 as input, and pin 3 and 4 as output?
 

nick12ab

Senior Member
"When using the PICAXE- system the four outputs down the right hand side of the
board are output pin numbers 0, 1, 2, and 4. The top input on the left hand side of
the board is pin3. The input connection marked ‘1’ is not used."
 

ternent

New Member
so i didn't think to hover over the bit that said 'click here for datasheet' :D

thanks very much for that, i will go and adjust then see how i get on.

I am using the right command for adjusting the output though yes?

low 0 doesnt seem to switch off the output as LED is staying Lit
 

BESQUEUT

Senior Member
Assuming output 2 is PinC.2 :
Code:
do
	do:loop until pin1=1
	high 0
	high 2
        do:loop until pin1=0
	low 0
	low 2
loop
Please, forgot GOTO command wich is only a good way to write confusing and erroneous program...

Do not use a confusing label : LOOP2 and LOOP4 are not loops !

Use
Code:
  and [ /CODE] to publish your code.

[I]NB : As the 2 outputs are synchronised you only need one output.[/I]
 

srnet

Senior Member
Please, forgot GOTO command wich is only a good way to write confusing and erroneous program...
Used appropriatly, and with care, there is nothing wrong with using GOTO.
 

BESQUEUT

Senior Member
Used appropriatly, and with care, there is nothing wrong with using GOTO.
Nothing wrong of course, but useless, very unreadable and I did saw GOTO command within a Subroutine...
What do you think of that one :
Code:
main:
b1=0
do
	inc b1
	GOSUB Routine
loop

Routine:
	if b1=5 then GOTO Main
return
It is very difficult to explain to a beginner why this is wrong...
so I prefer to say : "DO NOT USE GOTO COMMAND"
 
Last edited:

ternent

New Member
that way is much more simple than the way i have used so thanks.

i just used goto as its the way ive used it in the past for programming large program robots.

ok so the program is sorted, thanks :) but for some reason when i press the input, the output only comes on for a split second, even if i adjust it like so to prevent the program continuing too quickly.

Code:
do
	do:loop until pin1=1
	high 0
	high 2
	wait 1
        do:loop until pin1=1
	low 0
	low 2
	wait 1
loop
its a push to make switch so its always waiting for the pin to go high again before continuing with the program
 

BESQUEUT

Senior Member
Code:
do
	do:loop until pin1=1
	toggle 0
        toggle 1
	[S]wait 1[/S]
        do:loop until pin1=[COLOR="#FF0000"][B]0[/B][/COLOR]
	[S]wait 1[/S]
loop
This should be OK but you can try :
Code:
do
	do
              pause 100
        loop until pin1=1
	toggle 0
	toggle 2
        do
             pause 100
        loop until pin1=0
loop
 

ternent

New Member
Thats it!, thank you ever so much guys! i love these little pic chips but its been so so long since i last used them.

Thanks again for taking the time to offer your help and advice :)

Really appreciate it!
 

BESQUEUT

Senior Member
Hello srnet (and others !) : we are waiting for your advice about the code in #11...
 
Last edited:
Top