티스토리 뷰

SWDesk/Firmware

[FW] ATTiny85 PWM 예제

bizmaker 2024. 4. 2. 17:30
int previousValue = -1;

void setup() {
  // put your setup code here, to run once:

  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);


}

void loop() {
  // put your main code here, to run repeatedly:

  int value2 = analogRead(A3)/4;
  int value3 = analogRead(A2)/4;
  value2 = 255-value2;
  if(value2<10) value2 = 10;
  if(value2>200) value2 = 200;
  value3 = 255-value3;
  if(value3<10) value3 = 10;
  if(value3>200) value3 = 200;

  analogWrite(0, value2);
  analogWrite(1, value3);
 
  delay(500);

}

 
 

반응형