Lesson 6: Potentionmeter & LED
This lesson is about a Controlled LED brightness using Potentiometer . In our model, the brightness of the LED will depend on the rotation of the potentiometer knob. This is also one of the basic schemes. Link to original lesson: http://edurobots.ru/2014/04/arduino-potenciometr/ Hardware parts for this lesson: Arduino board Breadboard LED 220 Ohm resistor Jumpers (wires) Potentiometer Scheme on breadboard: Program code for this project: #define led 9 #define pot A0 void setup(){ pinMode(led, OUTPUT); pinMode(pot, INPUT); Serial.begin(9600); } void loop(){ int x; // read value of Potentiometer // as you remember A0-A5 pins working in range of 0-1023 // but analog INPUT/OUTPUT pins range is 0-255 // to get correct result we will divide result to 4 x = analogRead(pot) / 4; Serial.print("X="); Serial.println(x); // show result on LED analogWrite(led, x); } Task for Advanced students: Giv