Código Medidor De Carga Arduino.docx

  • Uploaded by: Oscar Galindo Fernandez
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Código Medidor De Carga Arduino.docx as PDF for free.

More details

  • Words: 224
  • Pages: 2
Código medidor de carga Arduino 1 // Pines para los LEDs 2 #define LEDVERDE 2 3 #define LEDAMARILLO 3 4 #define LEDROJO 4 5 #define ANALOGPILA 0 6 7 // Variables 8 int analogValor = 0; 9 float voltaje = 0; 10 int ledDelay = 800; 11 12 // Umbrales 13 float maximo = 1.6; 14 float medio = 1.4; 15 float minimo = 0.3; 16 17 void setup() { 18 // Iniciamos el monitor serie 19 Serial.begin(9600); 20 21 // Los pines de LED en modo salida 22 pinMode(LEDVERDE, OUTPUT); 23 pinMode(LEDAMARILLO, OUTPUT); 24 pinMode(LEDROJO, OUTPUT); 25 26 } 27 28 void loop() { 29 // Leemos valor de la entrada analógica 30 analogValor = analogRead(ANALOGPILA); 31

32 // Obtenemos el voltaje 33 voltaje = 0.0048 * analogValor; 34 Serial.print("Voltaje: "); 35 Serial.println(voltaje); 36 37 // Dependiendo del voltaje mostramos un LED u otro 38 if (voltaje >= maximo) 39 { 40

digitalWrite(LEDVERDE, HIGH);

41

delay(ledDelay);

42

digitalWrite(LEDVERDE, LOW);

43 } 44 else if (voltaje < maximo && voltaje > medio) 45 { 46

digitalWrite(LEDAMARILLO, HIGH);

47

delay(ledDelay);

48

digitalWrite(LEDAMARILLO, LOW);

49 } 50 else if (voltaje < medio && voltaje > minimo) 51 { 52

digitalWrite(LEDROJO, HIGH);

53

delay(ledDelay);

54

digitalWrite(LEDROJO, LOW);

55 } 56 57 // Apagamos todos los LEDs 58 digitalWrite(LEDVERDE, LOW); 59 digitalWrite(LEDAMARILLO, LOW); 60 digitalWrite(LEDROJO, LOW); 61 }

Related Documents

Medidor De Humedad.docx
November 2019 21
1 Medidor De P
December 2019 15
Medidor De Esr
May 2020 9
Taller Medidor De Ph
June 2020 11

More Documents from ""

December 2019 14
Gram Schimt.docx
December 2019 12
May 2020 5