I am trying to make a solar tracking system using a solar panel, some servos, and a python code in order to give the servos the right angle they need to be at. Unfortunately, I need the python code to be constantly updating the Arduino on what angle its supposed to be at, but I know this most likely isnt possible because you cant run the python code while the arduino code is going due to the port being taken up. Is there any possible way I could make this work so the python code is able to update the Arduinos angle and have both codes running at the same time.
you could run Micropython on an ESP32 or RP2040
have a look at ESP32 micropython introduction
Once your project is finished you no longer need the IDE so there is no problem.
It's only while developing that you encounter the problem that only one application can use the serial port.
You mean this python code is not running on the Arduino? Where is it running?
What would be taking the serial port up in this situation?
so im using pyserial in Vscode to get variables from the python code to the arduino IDE which then uses that to move the servos
What do you mean by this? Im fairly new to using arduinos this is my first time so Im not sure that I understand, at some point will I be able to program it without using the IDE?
So the answer to my first question is that the python code is running on a PC/laptop. To be precise it is running within VScode, which is itself an IDE.
The Arduino IDE is an app that also runs on your PC/laptop. What variables is your python code passing to the Arduino IDE and what does the Arduino IDE do with them? When these variables are passed, does the Arduino IDE re-compile and re-upload to the Arduino? That would explain why you say the Serial port is not available.
But why are you doing things this way? Why not pass the variables directly to the Arduino, via the serial port?
Im not really sure from what I saw online this was the best way to interact between python and arduino that I found, this is my first time working with a arduino or really doing anything involving rebotics so im very ignorant when it comes to how these things work. I didnt think you could go straight from python to Arduino. Im passing the data to the arduino IDE and then converting using that data to turn a servo to a specific angle.
You will always need the Arduino IDE (or similar) to program an Arduino board.
Once you have programmed the Arduino board to your satisfaction, you do not need the Arduino IDE.
I doubt that; you're passing data to the Arduino board. While the Arduino IDE (more specific serial monitor or the upload tool) have the port open you can not connect with your python application to the Arduino board; and vice versa, you can e.g. not upload to the Arduino board while the python application has the serial port in use.
So only during the development of the Arduino code you basically have a problem.
I've been using the Arduino IDE for 10 years or so and I didn't know you could do that!
I suspect you are misunderstanding what's going on here. It's not what you think, and the Arduino IDE can't do what you are saying it can do.
The Arduino IDE compiles and uploads the Arduino code to the Arduino board. The Arduino code does not run on the Arduino IDE, it runs on the Arduino board itself.
The Arduino IDE also has a feature called the Serial Monitor which is very useful for monitoring, interacting with and debugging the code running on the Arduino board. I suspect it is the Serial Monitor that is using the Serial port, so your python code cannot.
If you close the serial monitor, the serial port will become available for your python code to connect to and send data directly to the Arduino board (the Arduino IDE won't be involved at this point).
what is the project? where does VScode get the information to control the servos etc
could you implement the whole project on a ESP32 using Micropython and dump the PC and VScode?