CODE 6.11 | 적외선 센서로 바닥 색상 감지하기 (2)
| 01 | int irSensorPin = A0; // 적외선 센서의 A0를 연결한 아날로그 핀 |
| 02 | |
| 03 | void setup() { |
| 04 | Serial.begin(9600); // 시리얼 모니터 통신 시작 |
| 05 | } |
| 06 | |
| 07 | void loop() { |
| 08 | int sensorValue = analogRead(irSensorPin); |
| 09 | // 센서의 아날로그 값 읽기 |
| 10 | |
| 11 | Serial.print("Sensor Value: "); |
| 12 | Serial.println(sensorValue); // 읽은 값을 시리얼 모니터에 출력 |
| 13 | |
| 14 | delay(100); // 0.1초 대기 후 다시 측정 |
| 15 | } |
댓글 없음:
댓글 쓰기