Advertisement
Guest User

Untitled

a guest
Aug 8th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #define RELAIS_12V 11
  2.  
  3. int adc_12v_old = 0;
  4. int adc_12v = 0;
  5. int adc_12v_upper_limit = 647;  // 15V
  6. int adc_12v_lower_limit = 474;  // 11V
  7. int ADC_12V = 0;
  8.  
  9. void setup(void){
  10.     pinMode(RELAIS_12V, OUTPUT);
  11. }
  12.  
  13. void checkADC(void){
  14.     adc_12v = analogRead(ADC_12V);
  15.       if ((adc_12v > adc_12v_upper_limit) || (adc_12v < adc_12v_lower_limit)){
  16.         digitalWrite(RELAIS_12V, LOW);
  17.   }
  18.   else{
  19.       digitalWrite(RELAIS_12V, HIGH);
  20.   }
  21. }
  22.  
  23. void loop(){
  24.  checkADC();
  25.  delay(30);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement