Introduction
- In this article I will explain about measuring the Capacitor Range with Arduino Mega 2560.
- It can simply measure the capacitor range in the serial monitor.
Parts List
- Arduino Mega 2560
- Capacitor
- Hookup Wires
- Bread Board
Capacitor
- A capacitor (originally known as a condenser) is a passive two-terminal electrical component.
- It is used to store electrical energy temporarily in an electric field.
- In the two terminal it can have the postive and negative terminal
Figure 1: Capacitor
Connection
Step 1: Connecting From Arduino to capacitor.
- Connect the postive terminal to the digital pin of A1 to the board
- Connect the negative terminal to the A0 of the board
Programming:
- const int OUT_PIN = A1;
- const int IN_PIN = A0;
-
-
-
- const float IN_STRAY_CAP_TO_GND = 24.48;
- const float IN_EXTRA_CAP_TO_GND = 0.0;
- const float IN_CAP_TO_GND = IN_STRAY_CAP_TO_GND + IN_EXTRA_CAP_TO_GND;
- const int MAX_ADC_VALUE = 1023;
- void setup()
- {
- pinMode(OUT_PIN, OUTPUT);
-
- pinMode(IN_PIN, OUTPUT);
-
- Serial.begin(9600);
- }
- void loop()
- {
-
-
- pinMode(IN_PIN, INPUT);
- digitalWrite(OUT_PIN, HIGH);
- int val = analogRead(IN_PIN);
-
- pinMode(IN_PIN, OUTPUT);
-
- float capacitance = (float) val * IN_CAP_TO_GND /
- (float)(MAX_ADC_VALUE - val);
- Serial.print(F("Capacitance Value = "));
- Serial.print(capacitance, 3);
- Serial.print(F(" pF ("));
- Serial.print(val);
- Serial.println(F(") "));
- while (millis() % 500 != 0);
- }
Explanation
- In this article I explained about the measuring the range of the capacitor.
- It can print the value in the serial monitor.
Output
Figure 2: Output