tilt-swich basic programming... (newbie)

lambylamb

New Member
hey all! I am using the 18x project board, and .5 software too however basic is like golf to me, i know how to swing the club, but that doesnt mean the ball goes anywhere!!!!!

so im calling on ye wizards to help me, not because i cant be stuffed doing it muself, i just have no idea how at this stage! -->

i have 3 tilt-swiches connected to my inputs (correctly) the problem is some of them are 'on' and others 'off" but because the project i am workin on is moving (remote car) the swiches change. now its this CHANGE in after for example i only want the switches to activate certain outputs if there is a CHANGE in the high or low state in the inputs!

i only know how to write the code if 'on' or 'off'
please can someone help be with this bit of coding, i really would appreciate it.

cheers lamby.
 

craig008

New Member
all the guys here will want to know exsactly what you are trying to achieve but if this is any help you can use it.

the idea is based on a beach bag alarm, using the ADC to monitor the tilt switches, basically they were hooked in a potntial devider and when the alarm was switched on it read the ADC into the variable and then it checked the variable allow the alarm to be activated but not when it was julted a little.

yoou could do a similar thing with digital inputs a supose but you may ber better of comparing two tilt switches to avoid the ruff pumps showing as an activiation.

so if you have tilt swithes hooked up to pins 0 nad 1

if pin0 = 1 and pin1 = 1 then ....

have a look through the commands PDF it in help in the programming software, it will need to learn how to use the "if" command for sure
________
Volcano digital vaporizer
 
Last edited:

jodicalhon

New Member
I'm no expert, and may be missing some readily available command that will monitor the change in an input, however...

You could perhaps read the current state of the input(s), and put this state into a variable such as b0. Then regularly read the state of the input(s) and compare it to b0. When there is a difference, take the appropriate action. Put the now changed state into b0, then read the input(s) and compare as before.
 

BrendanP

Senior Member
Lamby, it might seem a bit of a pain but it is really helpfull to take the time to read and understand the picaxe manuals. As you read a command try and implement it on your project board if possible.
 

lambylamb

New Member
Sweet idea

I'm no expert, and may be missing some readily available command that will monitor the change in an input, however...

You could perhaps read the current state of the input(s), and put this state into a variable such as b0. Then regularly read the state of the input(s) and compare it to b0. When there is a difference, take the appropriate action. Put the now changed state into b0, then read the input(s) and compare as before.

, but how would this be written in BASIC??
Thats the prob!

i am staying away from ADC as it seems like over kill for this. also does anyone know what happened to the TUTEORIAL on picaxe.com? its a major dead link! and it would be very helpfull as far a learning goes!
 

BrendanP

Senior Member
You can try using the let pins= command.

You do something like
lets pins = b0 and then pause a second or whatever and then use lets pins=b1 then have a command if b1<>b0 then alarm or what ever you want to call it.
 

craig008

New Member
let b0 = pins
this will read all of the input pins into variable b0 which you can then do this
let b1 = pins
if b1 <> b0 then ...

let and if are more than likely the most important commends in the entire programme structure, thye allow for queries to ne made and subs to be run, you can not even be able to think about making any sort of programme without these basics.

i will give you a hint, start simple with an LED and push switch and see of you can get the PICAXE to moniter the input and then make the LED light up, pretty basic i know but that is where it starts. once you have done that make so the the button has to be press x number of times before lighting the led - and so on
________
WHOLESALE VAPORIZERS
 
Last edited:
Top