I am new to programming and am trying to communicate with my arduino using python through serial communication. I am using the following code:
Arduino code:
int ledPin = 11;
void setup() {
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop() {
digitalWrite(ledPin,LOW);
if (Serial.read() == 'M'){
digitalWrite(ledPin,HIGH);}
}
Python code:
import imaplib
import serial
ser = serial.Serial("COM3",9600)
ser.write(b'T')
ser.close()
I get the following error on running the python script:
serial.serialutil.SerialException: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)