페이지

2026년 6월 19일 금요일

6.4.2. 토양 습도 센서로 수분량 측정하기





CODE 6.7 | 토양 습도 센서 아날로그 값 읽기
01int soilPin = A0; // 토양 습도 센서를 연결한 아날로그 핀
02 
03void setup() {
04  Serial.begin(9600); // 시리얼 모니터 통신 시작
05}
06 
07void loop() {
08  int moistureValue = analogRead(soilPin); // 토양 습도 센서 값 읽기
09 
10  Serial.print("Soil Moisture Raw Value: ");
11  Serial.println(moistureValue); // 읽은 값을 시리얼 모니터에 출력
12 
13  delay(1000); // 1초 대기 후 다시 측정
14}




 

댓글 없음:

댓글 쓰기