This shows you the differences between two versions of the page.
|
arduino:analog_io:analogwrite [2013/02/15 19:05] 158.181.88.241 [Description] |
arduino:analog_io:analogwrite [2024/02/16 01:04] (current) |
||
|---|---|---|---|
| Line 32: | Line 32: | ||
| Sets the output to the LED proportional to the value read from the potentiometer. | Sets the output to the LED proportional to the value read from the potentiometer. | ||
| - | (:source lang=arduino:) | + | <code arduino> |
| int ledPin = 9; // LED connected to digital pin 9 | int ledPin = 9; // LED connected to digital pin 9 | ||
| int analogPin = 3; // potentiometer connected to analog pin 3 | int analogPin = 3; // potentiometer connected to analog pin 3 | ||
| Line 47: | Line 47: | ||
| analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255 | analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255 | ||
| } | } | ||
| - | (:sourceend:) | + | </code> |
| ====See also ==== | ====See also ==== | ||
| - | * [[arduino:analog io:AnalogRead]]() | + | * [[arduino:analog io:AnalogRead]] |
| - | * [[arduino:analog io:AnalogWriteResolution]]() | + | * [[arduino:analog io:AnalogWriteResolution]] |
| - | * [[Tutorial/PWM | Tutorial: PWM]] | + | |
| Source: arduino.cc | Source: arduino.cc | ||