페이지

12/12/2015

Led dimmer by using Potentiometer



Here's my codes,

const int LedPin = 3;
const int PotPin = 0;
static int val=0;

void setup() {
  pinMode(LedPin, OUTPUT);
}

void loop() {
  val = analogRead(PotPin);
  LedTune();

  analogWrite(LedPin, val);
}

void LedTune(){
  val = map(val, 0, 1023, 0, 255);
  val = constrain(val, 0, 255);
}

댓글 없음:

댓글 쓰기

블로그 보관함

Facebook

Advertising

Disqus Shortname

Popular Posts