Help learning how to create a Makefile

Thread Starter

jtplumbing

Joined May 23, 2020
1
Hello all I am new to Arduino and C++. I have used Arduino to make a USB device that runs on Windows 10. I now would like this Arduino code to use system variables to help decide what commands it runs. I have read that Arduino can not do this. The suggestion is to add your Arduino code to a Makefile. I am up for this. However, I cannot find any good tutorials on the web on how to do this. To be clear not how to use system variables in your sketch logic, but how to include your current sketch in a Makefile. Could someone point me to some instructions on how this is done using a Windows Computer? Thanks
 

Ian Rogers

Joined Dec 12, 2012
1,136
Can you explain a little more in detail.... The Arduino system runs differently dependant on the PC conditions?

If you explain a bit more there may be other ways of doing this..
 

pctechtv

Joined Aug 10, 2016
21
Can you explain a little more in detail.... The Arduino system runs differently dependant on the PC conditions?

If you explain a bit more there may be other ways of doing this..
Sure and thank for the reply. I have made a rotary encoder project. I am new to Arduino and this forum. Does including the sketch and a schematic do enough to explain my project? I will include them in the Attachments. I would like to know how to include them in a script that can access system information like environment variable. Know the best so I can learn how to do that would be super. I am not so bent on doing this the Makefile way, it is that I kept reading a Makefile would give access to more that Arduino does not have. I figured it my be my first step in understanding how software drivers are really made. For now I want the logic in my sketch to read in variables. Thanks for any help J--
 

Attachments

pctechtv

Joined Aug 10, 2016
21
Is the makefile the right target for what you intend to do?
Thanks for the reply. Above I explained some of why the Makefile suggestions I read online seemed to be what I want. I would like to know how to do this with a Makefile because it seems like a common thing. However I would like to hear any suggestion. Thanks
 

xox

Joined Sep 8, 2017
838
You could probably use plain old C to do this. You just need to write a program that can read your environment variables, write some #defines to an output file, read the original arduino sketch and write THAT to the output file and voila, you have a custom generated sketch file.
 
Top