Skip to content

Commit b2049a5

Browse files
committed
Add analogWrite example
1 parent 2849807 commit b2049a5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

examples/analogWrite/analogWrite.ino

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Portenta Breakout - analogWrite
3+
4+
The sketch shows how to use analogWrite API of the Portenta Breakout.
5+
6+
The circuit:
7+
- Portenta H7
8+
- Portenta Breakout
9+
10+
This example code is in the public domain.
11+
*/
12+
#include "Arduino_PortentaBreakout.h"
13+
14+
void setup() {
15+
Serial.begin(9600);
16+
while (!Serial);
17+
18+
//Default write resolution is 8bits
19+
Breakout.analogWriteResolution(8);
20+
21+
//PWM0 and PWM3 are using HRTIM peripheral and minimum frequency is 760Hz
22+
Breakout.analogWrite(PWM0, 25);
23+
Breakout.analogWrite(PWM1, 50);
24+
Breakout.analogWrite(PWM2, 75);
25+
Breakout.analogWrite(PWM3, 100);
26+
// PWM4 and PWM8 are sharing the same timer channel therefore is not possible
27+
// to use both outputs at the same time
28+
Breakout.analogWrite(PWM4, 125);
29+
Breakout.analogWrite(PWM5, 150);
30+
Breakout.analogWrite(PWM6, 175);
31+
Breakout.analogWrite(PWM7, 200);
32+
//Breakout.analogWrite(PWM8, 225);
33+
Breakout.analogWrite(PWM9, 250);
34+
}
35+
36+
void loop() {
37+
delay(100);
38+
}

0 commit comments

Comments
 (0)