We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ff5cf6 commit 0e44e69Copy full SHA for 0e44e69
PWM_LED_Control/PWM_LED_Control.ino
@@ -0,0 +1,27 @@
1
+/*
2
+ * PWM_LED_Control
3
+ * A simple combination of the AnalogReadSerial and Fade Arduino examples.
4
+ *
5
+ * Reads an analog input on pin 0, prints the result to the serial monitor,
6
+ * and PWM the LED on pin 9 using the analogWrite() function.
7
8
+ * Attach the center pin of a potentiometer to pin A0, and the outside pins to
9
+ * +5V and ground, and connect an LED to pin 9.
10
11
+ * This example code is in the public domain.
12
+ */
13
+
14
+const int pot_pin = 0;
15
+const int led_pin = 9;
16
17
+void setup() {
18
+ Serial.begin(9600);
19
+ Serial.println("Ready.");
20
+}
21
22
+void loop() {
23
+ int value = analogRead(pot_pin); // 0 <= N < 1024
24
+ analogWrite(led_pin, value / 4); // 0 <= N < 255
25
+ Serial.println(value);
26
+ delay(100);
27
0 commit comments