Hey friends
Brief:
I need to read voltages using an analog port A0 across a capacitor after supplying charging voltages by a digital port D2 using analogWrite(2,255); and print on serial monitor.
Details:
Kindly see the attached schematic.
I am supplying 2.5 volts to a capacitor which is connected to digital port D2 via a voltage divider (so to get 2.5 v from 5 v) and directly to analog port A0. I need to read the voltages across the capacitor when the digital port should not supply any voltages to the capacitor or you can say path between the digital port and capacitor via voltage divider should become open momentarily while I read voltages across the capacitor with analog port A0. I am wondering how I can implement this momentarily open digital port in code. Can anyone help me? Kindly help me.
Thanks for reading the problem.
My code:
int PEA = A0;
int PE = 2;
int temp_val_PE = 0;
float val_PE;
{
Serial.begin(9600);
pinMode(PE,OUTPUT);
Serial.print("PE Val");
}
void loop()
{
analogWrite(PE,255);
pinMode(PE,INPUT);
temp_val_PE = analogRead(PEA);
val_PE = temp_val_PE * (5.0 / 1023);
Serial.println("");
Serial.println(val_PE);
}
