You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/03.nano/boards/nano-r4/tutorials/01.user-manual/content.md
+157-3Lines changed: 157 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,13 +386,13 @@ Additionally, you can open the Arduino IDE's Serial Monitor (Tools > Serial Moni
386
386
387
387
This user manual section provides comprehensive information about the Nano R4's pin capabilities and functionality Understanding the board's pins capabilities and configurations is important for making the most of your projects with the Nano R4 board.
388
388
389
-
### Pin Overview
389
+
### Pins Overview
390
390
391
391
The Nano R4 features a total of **20 accessible pins** arranged in the classic Nano form factor, maintaining compatibility with existing Nano shields and breadboard layouts. These pins provide various functionalities including digital I/O, analog input, PWM output and several communication protocols.
The Nano R4's pins are organized into the following categories:
398
398
@@ -415,4 +415,158 @@ The following table shows the electrical specifications and operating limits for
415
415
|**Max Total Current**| 200 mA | Combined current for all pins |
416
416
|**Analog Reference**| +5 VDC | Default `AREF` voltage |
417
417
418
-
***<strong>Important safety considerations when working with the Nano R4 pins:</strong> Never exceed +5.5 VDC on any pin to avoid permanent damage, respect the 8 mA per pin and 200 mA total current limits, handle the board with proper anti-static precautions, avoid connecting pins directly to ground or power and always verify voltage levels when connecting +3.3 VDC devices.***
418
+
***<strong>Important safety considerations when working with the Nano R4 pins:</strong> Never exceed +5.5 VDC on any pin to avoid permanent damage, respect the 8 mA per pin and 200 mA total current limits, handle the board with proper anti-static precautions, avoid connecting pins directly to ground or power and always verify voltage levels when connecting +3.3 VDC devices.***
419
+
420
+
### Digital Pins
421
+
422
+
The Nano R4 features 14 digital pins (`D0` to `D13`) that can be configured as either digital inputs or digital outputs. These pins operate at +5 VDC logic levels and can source or sink up to 8 mA of current per pin. Digital pins are the foundation of most Arduino projects, allowing you to control LEDs, read button states, interface with sensors and communicate with other devices.
423
+
424
+
The Nano R4 digital pins provide the following functionality:
425
+
426
+
***<strong>Important note:</strong> Pins `D0` and `D1` are used for serial communication (UART) and should be avoided for general digital I/O when using Serial communication. Pins `D4` and `D`5 can be used for CAN bus communication. Pins `D10`, `D11`, `D12,` and `D13` are used for SPI communication.***
427
+
428
+
Digital pins can be configured and controlled using the following basic Arduino functions:
429
+
Pin Configuration:
430
+
arduinopinMode(pin, mode);
431
+
Digital Output:
432
+
arduinodigitalWrite(pin, value);
433
+
Digital Input:
434
+
arduinodigitalRead(pin);
435
+
436
+
### PWM (Pulse Width Modulation)
437
+
438
+
The Nano R4 board features multiple pins with PWM capability that can be used to generate analog-like output signals. PWM works by rapidly switching a digital output between `HIGH` and `LOW` states, where the ratio of `HIGH` time to the total period determines the effective analog voltage output.
439
+
440
+
The Nano R4 board provides PWM functionality on the following pins:
|`D11`|`P101`| Channel 5A | Digital I/O/SPI MOSI |
450
+
451
+
***<strong>Important note:</strong> Pins `A4` and `A5` also have PWM capability but are primarily used for I²C communication (SDA and SCL respectively). The onboard LEDs (`LEDR`, `LEDG`, `LEDB`, `LED_BUILTIN`) also support PWM for brightness control.***
452
+
453
+
You can use PWM pins as analog output pins with the `analogWrite()` function:
454
+
455
+
```arduino
456
+
analogWrite(pin, value);
457
+
```
458
+
459
+
By default, the resolution is 8-bit (0 to 255). You can use analogWriteResolution() to change this, supporting up to 12-bit (0 to 4095) resolution:
460
+
461
+
```arduino
462
+
analogWriteResolution(resolution);
463
+
```
464
+
465
+
***The following PWM examples use the built-in orange user LED (`LED_BUILTIN`) of the Nano R4 board, which supports PWM for brightness control. This eliminates the need for external components and allows you to test PWM functionality immediately.***
466
+
467
+
The following example demonstrates how to control the brightness of the built-in orange user LED using PWM:
468
+
469
+
```arduino
470
+
/**
471
+
PWM Example for the Arduino Nano R4 Board
472
+
Name: nano_r4_pwm_led.ino
473
+
Purpose: This sketch demonstrates how to use PWM to control
474
+
the brightness of the built-in user LED of the Nano R4 board.
475
+
476
+
@author Arduino Product Experience Team
477
+
@version 1.0 01/06/25
478
+
*/
479
+
480
+
// Built-in LED pin (supports PWM)
481
+
const int ledPin = LED_BUILTIN;
482
+
483
+
void setup() {
484
+
// Initialize serial communication at 115200 baud
485
+
Serial.begin(115200);
486
+
487
+
// No need to set pinMode for PWM pins - analogWrite() handles this
488
+
489
+
Serial.println("- Arduino Nano R4 - PWM LED Example started...");
490
+
Serial.println("- Built-in LED will fade in and out continuously");
491
+
}
492
+
493
+
void loop() {
494
+
// Fade in (0 to 255)
495
+
for (int brightness = 0; brightness <= 255; brightness++) {
496
+
analogWrite(ledPin, brightness);
497
+
delay(5);
498
+
}
499
+
500
+
Serial.println("- LED at maximum brightness");
501
+
delay(500);
502
+
503
+
// Fade out (255 to 0)
504
+
for (int brightness = 255; brightness >= 0; brightness--) {
505
+
analogWrite(ledPin, brightness);
506
+
delay(5);
507
+
}
508
+
509
+
Serial.println("- LED turned off");
510
+
delay(500);
511
+
}
512
+
```
513
+
514
+
You should now see the built-in orange user LED of your Nano R4 board gradually fade in and out, creating a smooth breathing effect that repeats continuously.
515
+
516
+
Additionally, you can open the Arduino IDE's Serial Monitor (Tools > Serial Monitor) to see the status messages that the example sketch sends at key brightness levels.
517
+
518
+
The following example demonstrates how to use a 12-bit PWM resolution for more precise control of the built-in orange user LED:
519
+
520
+
```arduino
521
+
/**
522
+
High-Resolution PWM Example for the Arduino Nano R4 Board
523
+
Name: nano_r4_pwm_high_res.ino
524
+
Purpose: This sketch demonstrates how to use 12-bit PWM resolution
525
+
for precise control of the built-in orange user LED brightness.
526
+
527
+
@author Arduino Product Experience Team
528
+
@version 1.0 01/06/25
529
+
*/
530
+
531
+
// Built-in LED pin (supports PWM)
532
+
const int pwmPin = LED_BUILTIN;
533
+
534
+
void setup() {
535
+
// Initialize serial communication at 115200 baud
536
+
Serial.begin(115200);
537
+
538
+
// Set PWM resolution to 12-bit (0-4095)
539
+
analogWriteResolution(12);
540
+
541
+
Serial.println("- Arduino Nano R4 - High-Resolution PWM Example started...");
542
+
Serial.println("- Using 12-bit resolution (0-4095) with built-in LED");
543
+
}
544
+
545
+
void loop() {
546
+
// Generate a smooth sine wave using 12-bit PWM
547
+
for (int i = 0; i < 360; i++) {
548
+
// Calculate sine wave value and map to 12-bit range
549
+
float sineValue = sin(i * PI / 180.0);
550
+
int pwmValue = (int)((sineValue + 1.0) * 2047.5); // Map -1 to 1 → 0 to 4095
551
+
552
+
analogWrite(pwmPin, pwmValue);
553
+
554
+
// Print current values every 30 degrees
555
+
if (i % 30 == 0) {
556
+
Serial.print("- Angle: ");
557
+
Serial.print(i);
558
+
Serial.print("°, PWM Value: ");
559
+
Serial.println(pwmValue);
560
+
}
561
+
562
+
delay(10);
563
+
}
564
+
565
+
Serial.println("- Sine wave cycle completed");
566
+
delay(1000);
567
+
}
568
+
```
569
+
570
+
This high-resolution example creates a smooth sine wave pattern with the built-in LED brightness, demonstrating the precision available with a 12-bit PWM resolution. You should see a very smooth transition in the LED brightness following a sine wave pattern.
571
+
572
+
Additionally, you can open the Arduino IDE's Serial Monitor (Tools > Serial Monitor) to see the angle and PWM value outputs that demonstrate the precise 12-bit control values being used.
0 commit comments