noam76

readSensor.h

Jul 23rd, 2021
986
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // read soil humiduty and display in html
  2. void getSoilHumidity() {
  3.   // Channel 0 (C0 pin - binary output 0,0,0,0)
  4.   digitalWrite(S0,LOW); digitalWrite(S1,LOW); digitalWrite(S2,LOW); digitalWrite(S3,LOW);
  5.   sensor[0] = analogRead(SIG);
  6.  
  7.   // Channel 1 (C1 pin - binary output 1,0,0,0)
  8.   digitalWrite(S0,HIGH); digitalWrite(S1,LOW); digitalWrite(S2,LOW); digitalWrite(S3,LOW);
  9.   sensor[1] = analogRead(SIG);
  10.  
  11.   // Channel 2 (C2 pin - binary output 0,1,0,0)
  12.   digitalWrite(S0,LOW); digitalWrite(S1,HIGH); digitalWrite(S2,LOW); digitalWrite(S3,LOW);
  13.   sensor[2] = analogRead(SIG);
  14.  
  15.   // Channel 3 (C3 pin - binary output 1,1,0,0)
  16.   digitalWrite(S0,HIGH); digitalWrite(S1,HIGH); digitalWrite(S2,LOW); digitalWrite(S3,LOW);
  17.   sensor[3] = analogRead(SIG);
  18.  
  19.   // Channel 4 (C4 pin - binary output 0,0,1,0)
  20.   digitalWrite(S0,LOW); digitalWrite(S1,LOW); digitalWrite(S2,HIGH); digitalWrite(S3,LOW);
  21.   sensor[4] = analogRead(SIG);
  22.  
  23.   // Channel 5 (C5 pin - binary output 1,0,1,0)
  24.   digitalWrite(S0,HIGH); digitalWrite(S1,LOW); digitalWrite(S2,HIGH); digitalWrite(S3,LOW);
  25.   sensor[5] = analogRead(SIG);
  26.  
  27.   // Channel 6 (C6 pin - binary output 0,1,1,0)
  28.   digitalWrite(S0,LOW); digitalWrite(S1,HIGH); digitalWrite(S2,HIGH); digitalWrite(S3,LOW);
  29.   sensor[6] = analogRead(SIG);
  30.  
  31.   // Channel 7 (C7 pin - binary output 1,1,1,0)
  32.   digitalWrite(S0,HIGH); digitalWrite(S1,HIGH); digitalWrite(S2,HIGH); digitalWrite(S3,LOW);
  33.   sensor[7] = analogRead(SIG);
  34.  
  35.   // Channel 8 (C8 pin - binary output 0,0,0,1)
  36.   digitalWrite(S0,LOW); digitalWrite(S1,LOW); digitalWrite(S2,LOW); digitalWrite(S3,HIGH);
  37.   sensor[8] = analogRead(SIG);
  38.  
  39.   // Channel 9 (C9 pin - binary output 1,0,0,1)
  40.   digitalWrite(S0,HIGH); digitalWrite(S1,LOW); digitalWrite(S2,LOW); digitalWrite(S3,HIGH);
  41.   sensor[9] = analogRead(SIG);
  42.  
  43.   // Channel 10 (C10 pin - binary output 0,1,0,1)
  44.   digitalWrite(S0,LOW); digitalWrite(S1,HIGH); digitalWrite(S2,LOW); digitalWrite(S3,HIGH);
  45.   sensor[10] = analogRead(SIG);
  46.  
  47.   // Channel 11 (C11 pin - binary output 1,1,0,1)
  48.   digitalWrite(S0,HIGH); digitalWrite(S1,HIGH); digitalWrite(S2,LOW); digitalWrite(S3,HIGH);
  49.   sensor[11] = analogRead(SIG);
  50.  
  51.   // Channel 12 (C12 pin - binary output 0,0,1,1)
  52.   digitalWrite(S0,LOW); digitalWrite(S1,LOW); digitalWrite(S2,HIGH); digitalWrite(S3,HIGH);
  53.   sensor[12] = analogRead(SIG);
  54.  
  55.   // Channel 13 (C13 pin - binary output 1,0,1,1)
  56.   digitalWrite(S0,HIGH); digitalWrite(S1,LOW); digitalWrite(S2,HIGH); digitalWrite(S3,HIGH);
  57.   sensor[13] = analogRead(SIG);
  58.  
  59.   // Channel 14 (C14 pin - binary output 0,1,1,1)
  60.   digitalWrite(S0,LOW); digitalWrite(S1,HIGH); digitalWrite(S2,HIGH); digitalWrite(S3,HIGH);
  61.   sensor[14] = analogRead(SIG);
  62.  
  63.   // Channel 15 (C15 pin - binary output 1,1,1,1)
  64.   digitalWrite(S0,HIGH); digitalWrite(S1,HIGH); digitalWrite(S2,HIGH); digitalWrite(S3,HIGH);
  65.   sensor[15] = analogRead(SIG);
  66. }
RAW Paste Data