my print command doesn't seem to work....I am using the nanpy-firmware to establish master-slave protocol with my arduino....when I apply hashtags to all the print commands, the program executes......when i don't it pops up a syntax error
the error is:
File"buttonLED.py", line 13
print("Failed to connect ot arduino")
^
SyntaxError: invalid character in identifier.
this was in a youtube tutorial....https://www.youtube.com/watch?v=QumIhvYtRKQ
the code is below:
Code: Select all
from nanpy import (ArduinoApi, SerialManager)
from time import sleep
ledPin = 7
buttonPin = 8
ledState = False
buttonState = 0
try:
connection = SerialManager()
a = ArduinoApi(connection = connection)
except:
print(¨Failed to connect to arduino¨)
#setup the pinmodes as if we were in ARDUINO IDE
a.pinMode(ledPin, a.OUTPUT)
a.pinMode(buttonPin,a.INPUT)
try:
while True:
buttonState = a.digitalRead(buttonPin)
print(¨Our button state is: {}¨.format(buttonState))
if buttonState:
if ledState:
a.digitalWrite(ledPin, a.LOW)
ledState = False
print(¨LED OFF¨)
sleep(1)
else:
a.digitalWrite(ledPin, a.HIGH)
ledState = True
print(¨LED ON¨)
sleep(1)
except:
a.digitalWrite(ledPin, a.LOW)