SHARE
TWEET

Untitled

a guest Oct 14th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import RPi.GPIO as GPIO
  2. import time
  3. import sys
  4. from flask import request
  5. from flask_api import FlaskAPI
  6.  
  7. app = FlaskAPI(__name__)
  8.  
  9. led_pin = 21    # Initializing pin 40 for led
  10. GPIO.setmode(GPIO.BCM)  # Using BCM numbering
  11. GPIO.setup(led_pin, GPIO.OUT)   # Declaring the pin 40 as output pin
  12. print("initialized")
  13.  
  14. @app.route('/',methods=["GET"])
  15. def turn_on_led():
  16.     print("called succesfully")
  17.     GPIO.output(led_pin, True)
  18.     time.sleep(0.2)
  19.     GPIO.output(led_pin, False)
  20.     time.sleep(0.2)
  21.     GPIO.output(led_pin, True)
  22.     time.sleep(0.2)
  23.     GPIO.output(led_pin, False)
  24.     time.sleep(0.2)
  25.     GPIO.output(led_pin, True)
  26.     time.sleep(0.2)
  27.     GPIO.output(led_pin, False)
  28.     return {
  29.     "Response":"alert shown"
  30.         }
  31.    
  32. if __name__ == "__main__":
  33.     app.run()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top