B4R Question Servo motor 90 degrees?

Discussion in 'B4R Questions' started by Beja, Apr 27, 2019.

  1. Beja

    Beja Expert Licensed User

    Hello all,
    After trying many times I utterly failed to return the servo motor from 90 degrees. It just stopped and didn't move. I was editing the Servo example by Erel, and replaced the 180 angel degrees to 90. what wrong am doing?
    Sub Process_Globals
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public Serial1 As Serial
    Public servo1 As Servo
    Public pinservo As Pin
    Public Timer1 As Timer
    Public angleservo As UInt
    Public upangle As Boolean

    End Sub

    Private Sub AppStart
        pinservo.Initialize (
    4,pinservo.MODE_OUTPUT)    'connect servo to pin 4 of Arduino
        servo1.Attach(pinservo.PinNumber)                'assign servo to device on pin servo

        Timer1.Initialize (
    "Timer1_Tick",100)            'Call Timer every second

    'initial servo angle
        upangle=True                                    'Increment angle

    End Sub

    Sub Timer1_Tick

    Select upangle                                    'Increment angle
    Case True
    If (angleservo >=0 And angleservo <180Then
    Log ("up angle ",angleservo)
                    angleservo=angleservo +
    End If
    If angleservo=180 Then upangle=False
    Case False                                    'Decrement angle
    If angleservo <=180 And angleservo>0 Then
    Log ("down angle ",angleservo)
    End If
    If angleservo=0 Then upangle=True
    End Select

    End Sub
  2. MikeSW17

    MikeSW17 Member

    Last edited: Apr 28, 2019
  3. Beja

    Beja Expert Licensed User

    Thanks Mike..
    Those were discussing a different thing.. But still no info aboutput how to stop at or return from 90 degrees ..
  4. Beja

    Beja Expert Licensed User

  5. tigrot

    tigrot Well-Known Member Licensed User

    Can you share your solution, pls?
  6. Beja

    Beja Expert Licensed User

    In fact it's not my solution.. Will confirm after testing it.
    tigrot likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice