please help. I'm new at this.
liquid12341234
Posts: 3
hi everybody. This I'd the first time I'm using a BS2 to control something. I'm trying to control a motor that only draws 1A. The circuit is done and I'm at the programming stage. My main power source is a 9 Volt battery. I installed a pushbutton on pin 8 as an input. I want the circuit to behave in a way where, when I press the button the time I hold the button is recorded into a variable. Thenthe controller will take this value and run my motor automatislly with the same duration I held the button. I was thinking of using a counter to record how long I held the button then decrement so the motor will run by itself. Any suggestions on how I should up about my little project? Thanks guys.
Comments
Andre'
time var word
length var word
sub:
if in1 = 1 then
gosub counter
else goto turnonmotor
counter:
time = time + 1
pause 5
gosub sub
' here I advise you to use the high command to turn on a transistor for your motor
turnonmotor:
length = time * 5
high 0
pause length
end
I hope this will work for you, and if I made a mistake, I'm really sorry. Hope it works for you. (p.s., incase you didn't notice, you need to put the name of the microcontroller and the pbasic version at the top)
Thanks for posting this routine
time var word
length var word
sub:
if in1 = 1 then
gosub counter
else goto turnonmotor
counter:
time = time + 1
pause 5
gosub sub
turnonmotor:
length = time * 5
high 0
pause length
end
I was thing of doing the same thing along the same line as what you want to but not to control a motor
liquid12341234
When I press the button the time I hold the button is recorded into a variable. Then the controller will take this value and run my motor automatislly with the same duration I held the button.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam