Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Capacimetro Digital para pF
- const int OUT_PIN = A4;
- const int IN_PIN = A0;
- long int acumulado=0;
- void setup(){
- pinMode(OUT_PIN, OUTPUT);
- pinMode(IN_PIN, OUTPUT);
- Serial.begin(9600);
- }
- void loop(){
- for(int i=0; i<150; i++){
- pinMode(IN_PIN, INPUT);
- digitalWrite(OUT_PIN, HIGH);
- int val = analogRead(IN_PIN);
- digitalWrite(OUT_PIN, LOW);
- pinMode(IN_PIN, OUTPUT);
- float capacitancia = (float)val * 24.5 / (float)(1023 - val);
- acumulado = capacitancia + acumulado;
- }
- Serial.print("Capacitor = ");
- Serial.print(acumulado/150);
- Serial.println("pF ");
- acumulado = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment