#!/usr/bin/python # -*- coding: utf-8 -*- import RPi.GPIO as GPIO # import RPi.GPIO module import time import json from pushbullet import Pushbullet # Define GPIO PUSH_SW = 40 LED_TX = 37 # Setup Access Token pb = Pushbullet("x9yiXMCXNh75DVhOcR7fx3hdnXrWAa7A") # Setup Pin refernce GPIO.setmode(GPIO.BOARD) # Setup Input pin with pull-up GPIO.setup(PUSH_SW, GPIO.IN, pull_up_down = GPIO.PUD_UP) # Setup Output pin GPIO.setup(LED_TX, GPIO.OUT) while True: i = GPIO.input(PUSH_SW) if(i != True): try: GPIO.output(LED_TX, True) time.sleep(0.25); GPIO.output(LED_TX, False) time.sleep(0.25); print("message sent") pb.push_note("ข้อความแจ้งเตือน", " ข้อความจาก Raspberry Pi") continue except Exception, e: raise e time.sleep(1)