Go Down

Topic: How to Run Arduino Code on another IDE without a board? (Read 341 times) previous topic - next topic

Jgunde

I used the Arduino IDE (because I know it well) to code a simulation to find the experimental probability of an event. My program runs thousands of times to do this. But it is really slow, seeing as it's running on a 16mghz Uno. Is there a relatively easy way to transfer the code to another platform on my computer which can run the code using my computer's processer (making it much faster)?

pert

Arduino code is essentially C++ (the IDE does do a couple of things for you so you can get away with writing code that's not quite valid C++). This means that it's theoretically possible to run Arduino code on your computer as C++. What you need to be aware of is that there is an Arduino core library that provides the standard Arduino functions like digitalWrite(), etc. You will not have that library on your computer so you would need to either implement your own version of any Arduino core library functions you're using, or else find alternative code. You also need to be aware that some microcontroller-specific code won't really have an equivalent on a standard computer. For example, digitalWrite() isn't going to make much sense.

So how difficult of a project this would be really depends on your code.

Robin2

I used the Arduino IDE (because I know it well) to code a simulation to find the experimental probability of an event. My program runs thousands of times to do this. But it is really slow, seeing as it's running on a 16mghz Uno. Is there a relatively easy way to transfer the code to another platform on my computer which can run the code using my computer's processer (making it much faster)?
I suspect the easiest thing to do would be to implement the same logic in a program specially written for your PC.

If you are just working with maths (and don't need hardware I/O) then I also suspect that the PC programming languages will make it easier.

On the other hand if you need hardware I/O then it can't be done on a PC.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Jgunde

My program does not uses any external hardware. It is only doing math operations using integers and arrays.

Robin2

My program does not uses any external hardware. It is only doing math operations using integers and arrays.
So write the program on the PC in Python.  Python has extensive maths libraries and is widely used in the scientific community.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up