저는 Arduino 보드를 사용하여 소프트 potmeter의 가치를 읽고 있습니다. (터치 감지 스트립). 스트립에 손이 닿는 한 완벽하게 작동합니다 (전류에 저항이 추가됨). 스트립을 건드리지 않으면 아날로그 핀이 완전히 랜덤 한 부동 번호를 읽습니다. 포럼에서는이 효과를 없애기 위해 풀업/풀다운 저항을 추가해야한다고 언급했으나 작동하지 않는 것으로 보입니다. 이 코드의 문제점은 무엇입니까?Arduino 풀업 저항이 작동하지 않습니다.
int potPin = 2;
int curval = 0;
// detect potmeter value
void setup() {
//enable pullup resistor, but still results in erratic output
//when potmeter is not touched
digitalWrite(potPin, HIGH);
//write to serial
Serial.begin(9600);
}
void loop() {
curval = analogRead(potPin);
// this works when the potmeter is being pressed (displays 0 to 1024)
Serial.println(curval);
delay(150);
}
설명해 주셔서 감사합니다. 나는 A2를 A로 바꿨고 실제로 풀업 저항이 작동하는 것으로 보인다. potmeter는 이제 임의의 부동 값 대신 항상 1024를 반환합니다. 하지만 지금은 화분에 손을 대면 아무 효과가 없습니다. 내가 필요로하는 것은 풀업 저항이 potmeter가 손댈 때만 작동한다는 것이다. 아니면 저항기를 사용하지 않고 Arduino 보드에 potmeter를 직접 연결할 때 불가능합니까? – Kokodoko