Arduino - Use Potentiometer To Control LED Brightness / Fade [SIMPLE]
CODE:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the Serial Monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop for the analog-to-digital
// converter to settle after the last reading:
delay(2);
}
Видео Arduino - Use Potentiometer To Control LED Brightness / Fade [SIMPLE] канала SnipWork
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the Serial Monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop for the analog-to-digital
// converter to settle after the last reading:
delay(2);
}
Видео Arduino - Use Potentiometer To Control LED Brightness / Fade [SIMPLE] канала SnipWork
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
How a simple remove background in video on iMovie (iPhone) [TUTORIAL for Beginner]Arduino - Blinking a LED [SIMPLE]3D Printed Baby Yoda [Wood Fill]3D Printed | #Rick and #Morty | WoodFill | TimeLapseBlender tutorial ako vytvorit shader Normal (modry obrazok)How to simple fix iPhone headphones. [TUTORIAL]100 Nemecké frázy pre začiatočnikov [časť 2]Nemčina pre stavbárov100 Nemecké frázy pre začiatočnikov [časť 3] 2023100 Nemeckých Fráz pre ZačiatočníkovArduino LCD backLight problem (SOLVED)Tunning Hoverboard [FAIL]3D Tlač | Štít v4 | Korona | pomoznemocnici [SPEED ART][PETG]Capture Desktop with VLC [TUTORIAL]Simple Blender TUTORIAL armature, Wall cycle (bones, inverse kinematics, weight painting, movement)