2 Replies Latest reply on Oct 4, 2018 5:30 PM by lui_gough

    Invalid Syntax -

    cevohcam

      Bought the Pi today with the kit, however am struggling whit the code. I can not for the life of me why I keep getting "invalid syntax" errors on line 27.

      Code from booklet

       

      import RPi.GPIO as GPIO
      import time
      
      GPIO.setmode(GPIO.BCM)
      
      LED = 21
      LS = 18
      
      GPIO.setup(LED,GPIO.OUT)
      
      def LSval (LSpin):
          reading = 0
          GPIO.setup(LSpin,GPIO.OUT)
          GPIO.output(LSpin,GPIO.LOW)
          time.sleep(0.3)
          GPIO.setup(LSpin,GPIO.IN)
          while (GPIO.input(LSpin) == GPIO.LOW):
              reading += 1
          return reading
      
      while True:
          i = LSval(LS)
          
          if LSval(LS) > 400:
              print("Dark",i)
              GPIO.output(LED,True)
          else
              print("Light",i)
              GPIO.output(LED,False)

       

      @Element 14, plz keep your documentation accurate. The booklet, in this case, is wrong.