Skip to content

Updated details of Arduino MKR1000 #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 2, 2019
Merged
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Language/Functions/Analog IO/analogWrite.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@ subCategories: [ "Analog I/O" ]

[float]
=== Description
Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady square wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()`) on the same pin. The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz.
Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady square wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()`) on the same pin.
[options="header"]
|================================================================================================================================================
| Board | PWM Pins | PWM Frequency
| Uno, Nano, Mini | 3, 5, 6, 9, 10 and 11 | 490 Hz, exception pin 5 and 6(980 Hz)
| Mega | 2 - 13 and 44 - 46 | 490 Hz, exception pin 4 and 13(980 Hz)
| Leonardo, Micro, Yún | 3, 5, 6, 9, 10 and 11 | 490 Hz, exception pin 3 and 11(980 Hz)
| Uno WiFi Rev.2 | 3, 5, 6, 9 and 10 | 490 Hz
| MKR boards | 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, A3 - or 18 -, A4 -or 19 | 732 Hz
| Zero | 3, 4, 5, 6, 8, 9, 10, 11, 12, 13 | 730 Hz
| Due | 3, 5, 6, 9, 10 and 11 | 1000 Hz
| 101 | 3, 5, 6 and 9 | 490 Hz
|================================================================================================================================================


[%hardbreaks]
On most Arduino boards (those with the ATmega168 or ATmega328P), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support `analogWrite()` on pins 9, 10, and 11.
The Arduino DUE supports `analogWrite()` on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs.

You do not need to call `pinMode()` to set the pin as an output before calling `analogWrite()`.
The `analogWrite` function has nothing to do with the analog pins or the `analogRead` function.
[%hardbreaks]
Expand Down