Will this program work?

reuben38121

New Member
Hi guys
will this program work? I cannot be bothered to use all the extra programing stuff for analouge sensors(in my case an LDR), unless I have to. Pin 1 in this case is the LDR. Here is the program:

let b1=1
main:
high 2
pause 750
high4
pause 250
low 2
low 4
high 0
pause 250
low 0
read 1,b1
if pin1=1 then goto sub
if pin1=0 then goto main

sub:
high 0
pause 250
low 0
read 1,b1
if pin1=1 then goto sub
if pin1=0 then goto main

I want it to work so that if the LDR is on, pin 0 is high. will this happen. what does b1=1 mean? Does it mean that when readadc(read 1,b1) reads the pin it translates it into 1, or high?

Please reply!





 
 

hippy

Ex-Staff (retired)
<i>will this program work? </i>

Probably, but I doubt it will do what you want it to.

<i>I cannot be bothered to use all the extra programing stuff for analouge sensors(in my case an LDR), unless I have to. </i>

I think that, &quot;you have to&quot;, is the best recommendation at present. Once you've become more familiar with the PICAXE and how it works, you can then start trying fancy tricks, and be able to experiment by yourself, while understanding the risk of damage to your chips which you may be taking. It is possible to use a digital input to read an analogue signal, but it is not recommended and Microchip caution that doing this may cause excessive current draw through the pin.

<i>what does b1=1 mean? Does it mean that when readadc(read 1,b1) reads the pin it translates it into 1, or high? </i>

&quot;b1=1&quot; assigns the value one into the byte variable named as 'b1'. &quot;READ 1,b1&quot; will read the byte of data at address one from the Data Eprom and put that value into 'b1' - it has nothing to do with analogue inputs.

I would suggest spending some time reading through PICAXE Manual 2 which describes the commands available in detail, and PICAXE Manual 3 shows how simple it is to interface an LDR and use the READADC command.

Edited by - hippy on 07/07/2006 05:42:17
 

BeanieBots

Moderator
No, it won't work. Do it properly in the first place and you will save more time than trying to cut corners.

Edited by - beaniebots on 07/07/2006 07:58:00
 

andrewpro

New Member
Just out of curiosity, is this a troll? Why cant you &quot;e bothered&quot; to do it right? It's no more code than you've already got there (well, technically two more lines).


--Andy P
 

andrewpro

New Member
Trolling is just like the fishing term of the same name (that's actually where it comes from). Essentially, it's posting something for no other reason than to get a reaction from someone or a group of people. Fishing for something, usually attempts at starting flame wars, etc. Just to get people riled up.

Google could probably give a better definition than me. Maybe wikipedia or soemthing, also.

--Andy P
 
Top