//Example Sketch using multiple analog sensors into one analog input pin
//Tutorials and more at http://www.cabuu.com

int Value_D7;
int Value_D8;
int Pin_D7 = 13;
int Pin_D8 = 15;

void setup() {

  Serial.begin(9600);   //Start serial monitor
  pinMode(Pin_D7,OUTPUT);
  pinMode(Pin_D8,OUTPUT);
  pinMode(A0,INPUT);
  
}

void loop() {
  
  digitalWrite(Pin_D7, HIGH);     //Turn D7 On
  delay(100);                     //Wait for sensor
  Value_D7 = analogRead(0);       //Read Analog pin as D7
  digitalWrite(Pin_D7, LOW);      //Turn D7 Off

  //Repeat for D8
  digitalWrite(Pin_D8, HIGH);     //Turn D8 On
  delay(100);                     //Wait for sensor
  Value_D8 = analogRead(0);       //Read Analog pin as D8
  digitalWrite(Pin_D8, LOW);      //Turn D8 Off
  delay(100);                     //Wait for sensor
  
  //Print the results to the serial monitor
  Serial.print("D7 = ");   
  Serial.print(Value_D7);
  Serial.print(" / D8 = ");   
  Serial.println(Value_D8);
    
}

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

− 2 = 1