Displaying result to Giga display shield

I have built an electromagnetic accelerator of which I have successfully used the ADC (A0) of the Arduino GIGA to measure the voltage via a voltage divider. it is accurate to within .01 volts. Currently I have the results of the measurement with the existing code outlined below outputting to my laptop.

I would like to output the results of each voltage measurement to the GIGA display shield instead so that I may see the status of each capacitors voltage on the GIGA display. Currently there will be (5) capacitors I would like to capture the voltage for from the accelerator with a max of about 10 when I am finished. If someone could help me with 2 lines of an output display voltage from 2 capacitors I can repeat the rest in the code as needed. Any help would be appreciated.

/*
* program is used to measure any voltage thru a voltage divider.
*/
const float arduinoVCC = 3.30;//Arduino voltage
unsigned long ValueR1 = 3000;
unsigned long ValueR2 = 19800;
double Voltage_Source = 25;
const int alanogPin = A0;//the pin connecting the voltage. 
const int inputResolution =1023;
const float average_of = 500;//Average of 500 readings

float voltage;
void setup() {
  Serial.begin(9600);
  Serial.println;
  delay(500);

}

void loop() {
  
  readVoltage();

  Serial.print("Vin: ");
  //Serial.print(voltage);
  //Serial.print("V Avg: ");
  Serial.print(getVoltageAverage());
  Serial.println("V");
  //delay(100);
  
}//loop end


/*
 * @brief calculates the input voltage and updates the variable "voltage"
 * @param none
 * @return does not return anything
 */
void readVoltage(){
    
    
    int A0Value = analogRead(alanogPin);
    float voltage_sensed = A0Value * (arduinoVCC / (float)inputResolution); 
//  Serial.print("voltage_sensed:");
//  Serial.print(voltage_sensed);       
  voltage = voltage_sensed * ( 1 + ( (float) ValueR2 /  (float) ValueR1) );
    
}//readVoltage()

/*
 * @brief calculates the average of input voltage and updates the variable "voltage"
 * @param none
 * @return retuns average of "average_of" iteration of voltage
 */
 
float getVoltageAverage(){
  
    
    float voltage_temp_average=0;
    for(int i=0; i < average_of; i++)
    {
       readVoltage();
       voltage_temp_average +=voltage;
    }
      
  return voltage_temp_average / average_of;
    
}//getVoltageAverage

Hi @adirks. I think the "Arduino_GigaDisplay_GFX" library will be suitable for this application.

You can learn how to use it from this tutorial:

https://docs.arduino.cc/tutorials/giga-display-shield/gfx-guide/

The important thing to understand is that the library's print and println functions work exactly the same as Serial.print and Serial.println. So you can use those functions to print the voltage values to the display in an equivalent manner as you would do to print to the Arduino IDE Serial Monitor.

I'll add an additional example that prints the value of millis() to the display:

#include <Arduino_GigaDisplay_GFX.h>

GigaDisplay_GFX display;

void setup() {
  display.begin();
  display.setTextSize(3);
  display.setTextColor(0xFFFF); // The argument is a 16-bit RGB color value.
}

void loop() {
  display.fillScreen(0x0000); // Clear the screen. 
  display.setCursor(70, 250); // Place the cursor at these coordinates on the display.
  display.print("millis: ");
  display.print(millis());
  delay(250);
}

Start by putting aside your real project sketch and simply uploading the simple sketches from the tutorial to your board. This will allow you to verify everything is working properly and learn the basics of how to use the library. Once you have done that, you will be able to easily integrate the library into your real sketch.

I thank you for taking the time to answer my question and to provide additional example information :slight_smile: I appreciate that and thank you again.

regards,

Alex

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per