페이지

레이블이 C인 게시물을 표시합니다. 모든 게시물 표시
레이블이 C인 게시물을 표시합니다. 모든 게시물 표시

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);
}

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