1/10/2014

(Arduino Study) LED control using potentiometer





...
int potPin = 0;
int ledPin = 13;

int val=0;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop(){
  val = analogRead(potPin);
  Serial.print(val);
  Serial.print("\n");
  digitalWrite(ledPin, HIGH);
  delay(val);
  digitalWrite(ledPin, LOW);
  delay(val);
}
--- LED brightness control using potentiometer ...
int potPin = 0;
int ledPin = 12;

int val=0;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop(){
  val = analogRead(potPin);
  Serial.print(val);
  Serial.print("\n");
  analogWrite(ledPin, val/4);
}
---

No comments:

Post a Comment