페이지

11/29/2015

Photoresistor, Arduino circuit.



Changing the light intensity of an LED by using a photo resistor.

And here's my codes,


const int PhotoPinNo = 0;
const int LedPinNo = 3;
int val;

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

void loop()
{
  val = analogRead(PhotoPinNo);

  BrightTune();

  analogWrite(LedPinNo, val);
}

void BrightTune()
{
  val = map(val, 450, 850, 255, 0);
  val = constrain(val, 0, 255);

댓글 없음:

댓글 쓰기

블로그 보관함

Facebook

Advertising

Disqus Shortname

Popular Posts