Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- import sys
- from flask import request
- from flask_api import FlaskAPI
- app = FlaskAPI(__name__)
- led_pin = 21 # Initializing pin 40 for led
- GPIO.setmode(GPIO.BCM) # Using BCM numbering
- GPIO.setup(led_pin, GPIO.OUT) # Declaring the pin 40 as output pin
- print("initialized")
- @app.route('/',methods=["GET"])
- def turn_on_led():
- print("called succesfully")
- GPIO.output(led_pin, True)
- time.sleep(0.2)
- GPIO.output(led_pin, False)
- time.sleep(0.2)
- GPIO.output(led_pin, True)
- time.sleep(0.2)
- GPIO.output(led_pin, False)
- time.sleep(0.2)
- GPIO.output(led_pin, True)
- time.sleep(0.2)
- GPIO.output(led_pin, False)
- return {
- "Response":"alert shown"
- }
- if __name__ == "__main__":
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement