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
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
No comments:
Post a Comment