'serial.serialutil.SerialException: could not open port 'COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
i'm making a web server that can contro an arduino with python and i get this error: serial.serialutil.SerialException: could not open port 'COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
from flask import Flask
from pyfirmata import Arduino
import time
main_page = """
<!DOCTYPE html>
<html>
<body>
<h2>Button</h2>
<form action="button">
<button type="submit">Press Button!</button>
<form>
</body>
</html>
"""
app = Flask(__name__)
@app.route('/button')
def button():
board = Arduino('COM3')
board.digital[13].write(1)
time.sleep(1)
board.digital[13].write(0)
print("hello")
return main_page
@app.route('/')
def index():
return main_page
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
Solution 1:[1]
had the same issue and by checking com3 in device manager i found it disabled, enabled it and it worked fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Moharam |