No I cant open serial moniter cause the terminal is open in python if I close that the whole code stops to work
Consider scheduling an appointment to meet with your instructor. You are not making any progress on this forum, because you won't post any useful information.
True...
Thanks for your help but unfortunately I will have to do by myself because I am not making progress
yes, that's what I wanted to double check.
I use this function in Python
def sendCommand(aCommand):
arduino.write(bytearray(aCommand, "utf8"))
arduino.write(b'\n') # end marker
and a command is a String
where arduino is my Serial port to the Arduino
arduinoPort = '/dev/cu.usbserial-A400Y6YX'
baudRate = 115200
arduino = serial.Serial(arduinoPort, baudrate=baudRate, timeout=.1)
Thanks
Is one of them in the Arduino ide? And if so which one.
No that is all Python code
Ok I fixed that problem but I am getting loads of error plz check my code:
from operator import index
import webbrowser
import time
import serial
A = input("What is your name?")
B = input("What is you age?")
C = input("What do you do as a hobby?")
D = input("What is the passcode?")
arduinoPort = '/dev/cu.usbserial-A400Y6YX'
baudRate = 115200
arduino = serial.Serial(arduinoPort, baudrate=baudRate, timeout=.1)
print("What is your name: " + A)
print("What is your age: " + B)
print("What do you do as a hobby: " + C)
A = str(A)
B = str(B)
C = str(C)
serialcomm = serial.Serial('COM3', 9600)
def sendCommand(aCommand):
while True:
serialcomm.timeout = 1
if D == "1289":
arduino.write(bytearray(aCommand, "1"))
arduino.write(b'\n') # end marker
print('1')
print("access granted")
else:
print('0', "Access denied.")
serialcomm.write(D.encode())
break
time.sleep(0.5)
print(serialcomm.readline().decode('ascii'))
serialcomm.close()
The forum broke it down a bit so ignore the broken parts. Anyways here are the errors:
And here is the code in a png format:
Please post with code tags don’t post picture of text
➜ please read How to get the best out of this forum and modify your post accordingly
Ok will do
I actually had posted more code here
➜ ($100 paid request) Serial/SafeString/Digital Read/Write bug is ruining my life - #44 by J-M-L
you can see a full python code waiting user commands that are sent to the Arduino
Hello I modified the code a bit(Python code) . The code is working nicely and the way I wanted it to but there is no input in the Arduino and I'm not sure why please check:
from operator import index
import serial
A = input("What is your name?")
B = input("What is you age?")
C = input("What do you do as a hobby?")
D = input("What is the passcode?")
arduinoPort = 'COM3'
baudRate = 115200
arduino = serial.Serial(arduinoPort, baudrate=baudRate, timeout=.1)
print("What is your name: " + A)
print("What is your age: " + B)
print("What do you do as a hobby: " + C)
A = str(A)
B = str(B)
C = str(C)
def sendCommand(aCommand):
if D == '1289':
print("Access granted")
arduino.write(bytearray(aCommand, "1"))
arduino.write(b'\n') # end marker
I only spend time reading posts following the guidelines
➜ please read How to get the best out of this forum and modify your post accordingly
from operator import index
import serial
A = input("What is your name?")
B = input("What is you age?")
C = input("What do you do as a hobby?")
D = input("What is the passcode?")
arduinoPort = 'COM3'
baudRate = 115200
arduino = serial.Serial(arduinoPort, baudrate=baudRate, timeout=.1)
print("What is your name: " + A)
print("What is your age: " + B)
print("What do you do as a hobby: " + C)
A = str(A)
B = str(B)
C = str(C)
def sendCommand(aCommand):
if D == '1289':
print("Access granted")
arduino.write(bytearray(aCommand, "1"))
arduino.write(b'\n') # end marker`Preformatted text
`
This is the code and I have written the problem in the previous posts. This is the line of code
that sends the signal right?
arduino.write(bytearray(aCommand, "1"))
Def is to introduce a function definition. What’s your function doing and are you calling it?
If you have
def sendCommand(aCommand):
arduino.write(bytearray(aCommand, "utf8"))
arduino.write(b'\n') # end marker
Then you could call
sendCommand(A)
If you want to send the age