I am trying to make a program for arduino also using Python 2.7 and pySerial that will put tweets on a lcd my only problem is the Python code it is giving me a error My code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tweepy
import serial
import time
from datetime import datetime
import pytz
import signal
import sys
def exit_handler(signal, frame):
global s
print 'You pressed Ctrl+C!'
print 'Closing properly'
s.write(chr(10))
s.close()
sys.exit(0)
s = serial.Serial("/dev/ttyACM0" ,9600, timeout=10)
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_KEY = ''
ACCESS_SECRET = ''
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
tweets = api.user_timeline(count = 1)
print "Wait a moment please"
signal.signal(signal.SIGINT, exit_handler)
time.sleep(4)
tweet = tweets[0].text
while len(tweet) < 26:
tweet = tweet + " "
#Adjust to local timezone
eastern = pytz.timezone('US/Eastern')
utc = pytz.timezone('UTC')
tweet_time = utc.normalize(utc.localize(tweets[0].created_at))
tweet_time_local = str(tweet_time.astimezone(eastern))
s.write(chr(13))
s.write(tweet[0:16])
s.write(chr(10))
# We need a small delay
time.sleep(0.1)
s.write(tweet[16:26])
time.sleep(0.1)
s.write(" ")
time.sleep(0.1)
s.write(tweet_time_local[11:16])
s.close()
The error
Traceback (most recent call last):
File "twitter_lcd.py", line 23, in <module>
s = serial.Serial("/dev/ttyACM0" ,9600, timeout=10)
File "build/bdist.cygwin-2.4.1-x86_64/egg/serial/serialutil.py", line 180,
File "build/bdist.cygwin-2.4.1-x86_64/egg/serial/serialposix.py", line 294, e in open
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
Any help is appreciated
- Windows 10
- Arduino Uno R3