0% found this document useful (0 votes)
27 views3 pages

LC Arduino

Uploaded by

kuetecedric0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

LC Arduino

Uploaded by

kuetecedric0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<LiquidCrystal.

h>
LiquidCrystal lcd(A5, A4, A3, A2, A1, A0);
#define serial
#define charge 3
#define freqIn 2
#define mode 10
#define Delay 15
double frequency, capacitance, inductance;
typedef struct
{
int flag: 1;
}Flag;
Flag Bit;
void setup()
{
#ifdef serial
Serial.begin(9600);
#endif
lcd.begin(16, 2);
pinMode(freqIn, INPUT);
pinMode(charge, OUTPUT);
pinMode(mode, INPUT_PULLUP);
lcd.print(" LC Meter Using ");
lcd.setCursor(0, 1);
lcd.print(" Arduino ");
delay(2000);
lcd.clear();
lcd.print("Circuit Digest");
delay(2000);
}
void loop()
{
for(int i=0;i<Delay;i++)
{
digitalWrite(charge, HIGH);
delayMicroseconds(100);
digitalWrite(charge, LOW);
delayMicroseconds(50);
double Pulse = pulseIn(freqIn, HIGH, 10000);
if (Pulse > 0.1)
frequency+= 1.E6 / (2 * Pulse);
delay(20);
}
frequency/=Delay;
#ifdef serial
Serial.print("frequency:");
Serial.print( frequency );
Serial.print(" Hz ");
#endif
lcd.setCursor(0, 0);
lcd.print("freq:");
lcd.print( frequency );
lcd.print(" Hz ");
if (Bit.flag)
{
inductance = 1.E-3;
capacitance = ((1. / (inductance * frequency * frequency * 4.*3.14159 * 3.
14159)) * 1.E9);
if((int)capacitance < 0)
capacitance=0;
#ifdef serial
Serial.print("Capacitance:");
Serial.print( capacitance,6);
Serial.println(" uF ");
#endif
lcd.setCursor(0, 1);
lcd.print("Cap: ");
if(capacitance > 47)
{
lcd.print( (capacitance/1000));
lcd.print(" uF ");
}
else
{
lcd.print(capacitance);
lcd.print(" nF ");
}
}

else
{
capacitance = 0.1E-6;
inductance = (1. / (capacitance * frequency * frequency * 4.*3.14159 * 3.
14159)) * 1.E6;
#ifdef serial
Serial.print("Ind:");
if(inductance>=1000)
{
Serial.print( inductance/1000 );
Serial.println(" mH");
}
else
{
Serial.print( inductance );
Serial.println(" uH");
}
#endif
lcd.setCursor(0, 1);
lcd.print("Ind:");
if(inductance>=1000)
{
lcd.print( inductance/1000 );
lcd.print(" mH ");
}
else
{
lcd.print( inductance );
lcd.print(" uH ");
}
}
if (digitalRead(mode) == LOW)
{
Bit.flag = !Bit.flag;
delay(1000);
while (digitalRead(mode) == LOW);
}
delay(50);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy