Created
December 17, 2017 19:02
-
-
Save iotguider/ac3a7c80803a66bbfeca039f46a8781e to your computer and use it in GitHub Desktop.
Code for Sending SMS from Raspberry Pi using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import os | |
import sys | |
push_button = 23 | |
led = 18 | |
def setup(): | |
GPIO.setmode(GPIO.BCM) # Numbers GPIOs by physical location | |
GPIO.setup(led,GPIO.OUT) | |
GPIO.setup(button,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) | |
def destroy(): | |
GPIO.output(17, GPIO.LOW) # led off | |
if _name_ == "_main_": # Program start from here | |
setup() | |
try: | |
if(GPIO.input(push_button) == True): | |
GPIO.output(18,GPIO.HIGH) | |
print("sms sent") | |
os.system("python send_sms.py") #Using this line in any python program you can send sms. This call the send_sms.py program and runs it. | |
break | |
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed. | |
destroy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment