Wednesday, 10 February 2021

Task#2___Control brightness of a LED by using a variable resistance

The objective of the task is to control the brightness of a LED by a variable resistance like below.

        - Input: 1 pin for a variable resistance
        - Output: 1 pin for three LED 
  • Making 
    • Circuit board     



We should know about PWM for map() function first for make to easy to build.




  • Coding
                    int pinled = 11;
                    int pinPotentiometer = 0;
                    int valueA0 = 0;

                    void setup() {
                     pinMode(pinled, OUTPUT);

                    }
                    void loop() {
                     valueA0 = analogRead(pinPotentiometer);
                     valueA0 = map(valueA0,0,1023,0,255);
                     analogWrite(pinled, valueA0);
                    









 //Prepared by Rothny
 // lead by Dr. Kwanghoon Kim

No comments:

Post a Comment