• Home
  • /
  • อ่านค่า 5-way Senser Infrared + Arduino Nano

อ่านค่า 5-way Senser Infrared + Arduino Nano

//อ่านค่าจากเซ็นดซอร์ ทั้ง5ตัว
const int analogInPin1 = A3;
const int analogInPin2 = A4;
const int analogInPin3 = A5;
const int analogInPin4 = A6;
const int analogInPin5 = A7;
int sensorValue1; int sensorValue2; int sensorValue3; int sensorValue4; int sensorValue5;
void setup() {
Serial.begin(9600);
}

void loop() {
sensorValue1 = analogRead(analogInPin1);
Serial.print(“sensor1= “);
Serial.print(sensorValue1);
Serial.print(” “);
//=========================
sensorValue2 = analogRead(analogInPin2);
Serial.print(“sensor2= “);
Serial.print(sensorValue2);
Serial.print(” “);
//=========================
sensorValue3 = analogRead(analogInPin3);
Serial.print(“sensor3= “);
Serial.print(sensorValue3);
Serial.print(” “);
//=========================
sensorValue4 = analogRead(analogInPin4);
Serial.print(“sensor4= “);
Serial.print(sensorValue4);
Serial.print(” “);
sensorValue5 = analogRead(analogInPin5);
Serial.print(“sensor5= “);
Serial.print(sensorValue5);
Serial.println(” “);
delay(2);
}

//ครูหนุ่ม

Leave Your Comment Here