Sign in

username:

password:



Not a member?

Search oopic



Search tips

Subscribe to oopic



Ads

Discussion Groups

Discussion Groups | | 2 microswitch

2 microswitch - joeycorp23 - Jul 31 10:35:20 2008

Please help me out of this problem..

I have two microswitch that will control the direction of the motor.
if one microswitch was pushed, the motor will turn clockwise
continously until the other microswitch was pushed to change the
direction of the motor. please check my code:

Dim speedMotor1 As New oKnob
Dim speedMotor2 As New oKnob
Dim motor1 As New oDCMotor
Dim motor2 As New oDCMotor
Dim switchClockwise As New oButton
Dim switchCounter As New oButton

Sub Main
speedMotor1.IOLine = 1
speedMotor1.Operate = cvOn

speedMotor2.IOLine = 2
speedMotor2.Operate = cvOn

motor1.IOLineP = 17
motor1.IOLineD = 27
motor1.IOLineB = 25
motor1.Unsigned = 0

motor2.IOLineP = 18
motor2.IOLineD = 26
motor2.IOLineB = 24
motor2.Operate = 1

switchClockwise.IOLine = 8
switchClockwise.Mode = 1
switchClockwise.Position = cvOff

switchCounter.IOLine = 9
switchCounter.Mode = 1
switchCounter.Position = cvOff

Do
If switchClockwise.IsOn Then
switchCounter.Position = cvOff
Call motorClockwise()
End If

If switchCounter.IsOn Then
switchClockwise.Position = cvOff
Call motorCounter()
End If

motor2.Speed = speedMotor2.Position

Loop
End Sub
Sub motorClockwise()
motor1.Direction = 0
Do
motor1.Speed = speedMotor1.Position
Loop
End Sub

Sub motorCounter()
motor1.Direction = 1
Do
motor1.Speed = speedMotor1.Position
Loop
End Sub

------------------------------------



(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )