I built a hardware interface to scale and convert AC voltage to DC. In my code, I have simple program that is measuring the DC voltage on A0 and converting it to the AC voltage reading for my 4x20 display. There are a few conditional statements for types of measurement and when it is measured. But each time I want the code to display the value for the various condition, I write out all the lines below.
I'm having a hard time understanding if I can condense this into a function? It looks like a function already, but this is where I get confused.
@jremington , thank you for the reply. The conditions do not affect the lines; they are about when to measure based on timing.
I watched a few videos about the [example] void displayVAC() { do stuff here } functions. The videos say to place the void statement at the end of the code loop. Meaning after the last }. Is that correct? Do I need to define 'displayVAC' in the setup or loop then? This is where I'm getting the most confused.
Try the posted code and see if it works! Copy and paste it in just before the functions setup() or loop() in your Arduino program, and call it where ever you like.
Don't bother with youtube videos, as many of those are produced by people who have little to no idea what they are doing.
I recommend to study published tutorials in C/C++ from reliable sources, like this randomly chosen example on functions.
LOL, I have little to no clue what I am doing. Actually, I managed to write a decent code to measure and display values with two buttons doing multiple operations. I'm not a coder; I'm a hardware guy.
I will try this later and report back. My project is not in front of me right now. I appreciate the help.
@jremington I was able to breakaway from work and give it a go. Works perfect. Thanks for the help. I have two different books about Arduino code and neither really provide great detail on this topic. Also, most examples of topics are either based on LEDs or basic math. I get it, great ways to relate the info. But I'm usually looking for way different applications of said topics and it takes me a while to figure it out.
Here is my finished project to measure audio power amps. My prototype is below with the smaller display.