2025년 7월 8일 화요일

가변 저항






소스 코드 예시
int potPin = A0;  

void setup() {
  Serial.begin(9600);  
}

void loop() {
  int potValue = analogRead(potPin); 
  Serial.println(potValue); 
  delay(500);  
}






소스 코드 예시
int sensorValue;
int outputValue;

void setup() {
  pinMode(A0, INPUT);
  pinMode(9, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(A0);
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  analogWrite(9, outputValue);
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);
  delay(2);
}



댓글 없음:

댓글 쓰기