Python to xojo

  1. 10 months ago

    Gurdip G

    31 Jul 2019 Testers, Xojo Pro http://www.nextgenoffices.com

    Hi All,

    Can anyone translate this python code to xojo?

    import RPi.GPIO as GPIO
    from time import sleep

    GPIO.setmode(GPIO.BOARD)

    Motor1A = 16
    Motor1B = 18
    Motor1E = 22

    GPIO.setup(Motor1A,GPIO.OUT)
    GPIO.setup(Motor1B,GPIO.OUT)
    GPIO.setup(Motor1E,GPIO.OUT)

    print "Turning motor on"
    GPIO.output(Motor1A,GPIO.HIGH)
    GPIO.output(Motor1B,GPIO.LOW)
    GPIO.output(Motor1E,GPIO.HIGH)

    sleep(2)

    print "Stopping motor"
    GPIO.output(Motor1E,GPIO.LOW)

    GPIO.cleanup()

    This is what I have tried but does not work,

    GPIO.SetupGPIO

    Const Motor1A = 16
    Const Motor1B = 18
    Const Motor1E = 22

    ' Set the pin to accept output
    GPIO.PinMode(Motor1A, GPIO.OUTPUT)
    GPIO.PinMode(Motor1B,GPIO.OUTPUT)
    GPIO.PinMode(Motor1E,GPIO.OUTPUT)

    GPIO.DigitalWrite(Motor1A, GPIO.HIGH)
    GPIO.DigitalWrite(Motor1B, GPIO.LOW)
    GPIO.DigitalWrite(Motor1E, GPIO.HIGH)

    App.DoEvents(500)

    GPIO.Cleanup

    Thanks

  2. You should use CODE tags for posting code.

    https://docs.xojo.com/UserGuide:Raspberry_Pi_GPIO

    https://docs.xojo.com/GettingStarted:Raspberry_Pi_Blinking_LED_Tutorial

    https://einhugur.com/blog/index.php/xojo-gpio/

or Sign Up to reply!