페이지

2026년 6월 15일 월요일

5.4.2. 가변 저항으로 아날로그 값 읽기




CODE 5.15 | 가변 저항 아날로그 값 읽기
01int potPin = A0; // 가변 저항을 연결한 아날로그 핀
02 
03void setup() {
04  Serial.begin(9600); // 시리얼 모니터 통신 시작
05}
06 
07void loop() {
08  int sensorValue = analogRead(potPin); // 가변 저항 값 읽기
09 
10  Serial.print("Value: ");
11  Serial.println(sensorValue); // 읽은 값을 시리얼 모니터에 출력
12 
13  delay(100); // 0.1초 대기 후 다시 측정
14}


 

댓글 없음:

댓글 쓰기