Professional Documents
Culture Documents
BATCH1
CONTROLLING LED USING TELEGRAM BOT
Hardware Requirements
2. LED
3. Breadboard
4. Jumper Wires
Install python-pip and telepot on the system using the below commands
respectively..
import MessageLoop
red = 21
now = datetime.now()
GPIO.setmode (GPIO.BCM)
GPIO.setwarnings (False)
GPIO.output(red,0)
def action(msg):
chat_id = msg['chat']['id']
command = msg['text']
if 'on' in command:
message = "on"
if 'red':
GPIO.output (red, 1)
message = "off"
if 'red' in command:
GPIO.output (red, 0)
telegran_bot = telepot.Bot('915524308:
AAGmc_b1H9E_XvMfnMKTaExWqPL40ttbAdo')print (telegram_bot.getMe())
MessageLoop(telegram_bot, action).run_as_thread() p
while 1:
time. sleep(10)
OUTPUT:
Output video is also posted in classwork along with this document as an external
file