Converting a CSV file to Arduino code

Not open for further replies.

Thread Starter


Joined Aug 9, 2017
Hi All,

Is it possible to convert a CSV file into code? I am trying to replicate a signal from another microcontroller and output the same signal from the Arduino.

Please find attached the CSV file.




Joined Oct 29, 2009
You are providing a file that looks like the output of a scope not code. So your no. The Arduino is not magic. It is just a computer capable of outputting either a 0 or 5V out (I do not thing it has analog out but if it did it would be 0-5V). And it needs to be programmed to do all of that.

Not only will you need to write the code, you are going to have to design a circuit that is capable of producing negative voltages from what looks like -0.2 to -0,312 volts,


Joined Jun 4, 2014
Is it possible to convert a CSV file into code? I am trying to replicate a signal from another microcontroller and output the same signal from the Arduino.
No, I'm afraid it is not that simple. You are going to have to note how many samples the signal is high, then how many low and so on to the end of the signal. Each sample is 0.5uS so when you know how many samples the signal was low/high you can calculate how long it was in that state. Then all (;):eek:) you have to do is to write the code that will output a signal to match those timings.


Joined Apr 10, 2015
YOU can write the code for the Arduino to produce an output based on an input. You can use an output from your other controller to drive that Arduino input.

You can (and most likely will) use another "controller" (your PC) to produce your Arduino program code, and must use one to load it into the Arduino. That being the case, you could program a controller to "automatically" produce code based on input -other than your keyboard entry-level which would then be loaded into an Arduino and executed. It seems you realize that, and want to do it.

The action of the Arduinos outputs are of course determined by the code that the CPU chip is executing, but we generally use the inputs as the primary means of determining the action of the outputs. If you need to entirely electrically isolate the Arduino from the other controller, optic isolation circuits can be used.


Joined Oct 29, 2013
Yes, kinda sorta, assuming the limitations of the Arduino are OK for your case. The Arduino has analog output features on a few pins (depending on which Arduino you're using), but what it actually gives you is a PWM output and the analog value that you write to the pin changes the duty cycle. While you could add more components to filter this into an analog signal, there would be limitations and I do not recommend doing it this way.

Instead use an external DAC. Write a script to convert your CSV file to a C array (assuming the Arduino has enough memory for all of your data), then write your Arduino code to parse the array and send the values to an external DAC. Now you will get real analog output to match your values. Here is an example device with a HowTo:

If your data is too big to fit into the Arduino memory, then you can instead put the data on an SD card, then use the Arduino to read the data from the SD card and send the values to the DAC. Here is an example SD card reader for Arduino:

I haven't used either of these myself, but check around and there are likely Arduino libraries that will help you communicate with them. Also draw out the Arduino and these modules on paper, and draw lines connecting the proper pins to each device. Sometimes only specific pins work for specific things, for example an Arduino UNO only has SPI hardware support on pins 11, 12 and 13. So by drawing it out, you can be sure that the necessary pins aren't already being used for something else, etc..
Not open for further replies.