Wednesday, April 1, 2020

Changing LED blinking rate by a variable resistor.

  • এখানে আমরা একটি variable resistor ( ফটোসরিস্টর) ব্যবহার করি,
  • আমরা একটি আরডুইনো বোর্ডের এক অ্যানালগ ইনপুট ব্যবহার করে এর মানটি Read করি এবং সেই অনুযায়ী দুই নাম্বার পিনে যুক্ত LED blinking rate পরিবর্তন করি।
  • Variable resistor এর অ্যানালগ মানটি ভোল্টেজ হিসাবে Read করা হয় কারণ এনালগ ইনপুটগুলি এভাবে কাজ করে।

Code:
int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 1;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() 
{                                          
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT:
}
void loop() 
{
    sensorValue = analogRead(sensorPin);  // read the value from the sensor:
    digitalWrite(ledPin, HIGH);                      // turn the ledPin on
    delay(sensorValue);   // stop the program for <sensorValue> milliseconds:
    digitalWrite(ledPin, LOW);                  // turn the ledPin off:
    delay(sensorValue);                   // stop the program for for <sensorValue>                                                                                  //milliseconds:
}

No comments:

Post a Comment