Advertisement
franciscominajas

Untitled

Nov 30th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. void setup()
  2. {
  3.   pinMode(13, OUTPUT);          // sets the digital pin 13 as output
  4.   pinMode(12, OUTPUT);          // sets the digital pin 12 as output
  5.   Serial.begin(9600);
  6. }
  7.  
  8. void loop()
  9. {
  10.   int valorADC;
  11.   float voltaje;
  12.   valorADC = analogRead(A5);
  13.   voltaje = valorADC * (5.0 / 1023.0);
  14.   Serial.println(voltaje);
  15.   if(voltaje>4.5)
  16.   {
  17.     digitalWrite(12, HIGH);       // sets the digital pin 13 on
  18.     //delay(1000);                  // waits for a second
  19.     digitalWrite(13, LOW);        // sets the digital pin 13 off
  20.     //delay(1000);                  // waits for a second
  21.   }
  22.   else
  23.   {
  24.     digitalWrite(13, HIGH);       // sets the digital pin 13 on
  25.     //delay(1000);                  // waits for a second
  26.     digitalWrite(12, LOW);        // sets the digital pin 13 off
  27.     //delay(1000);                  // waits for a second
  28.   }
  29.   delay(2);  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement