Maker.io main logo

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

2024-10-14 | By Travis Foss

Arduino ESP32 Qwiic

Have you wanted to try the newest Arduino Uno boards, such as the Uno R4 Minima or Uno R4 WiFi? Here is a QuickStart guide to get your first bit of code up and running within a matter of minutes.

Things you will need to get the initial code working are a version of the Uno R4 boards, either the Arduino Uno R4 Minima or the Arduino Uno R4 WiFi, and a USB C cable. A secondary option would be to purchase the Arduino Plug and Make Kit which comes with the Arduino Uno R4 WiFi, along with a USB cable, and also some Modulino boards with Qwiic connectors to connect those Modulinos to the R4 WiFi board. It also includes a mounting plate to mount all the individual pieces as well.

To get started with the code, I recommend installing the latest version of the Arduino IDE. You can download that latest version from this page: Software | Arduino.

Once the software is installed, it is time to install the board files in the IDE. To do this click on the Boards Manager button, located on the left-hand side, and the second button down. In the search bar near the top, type in Arduino Uno R4. The Arduino Uno R4 boards package will appear. Click the install button to install this board package.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

With this board package installed, it is time to start coding. First, connect the Uno R4 board to your computer by plugging your USB C cable into the USB socket on the board. Next, plug the other end of the cable into your computer. If you are using the R4 WiFi, once the cable is connected, you will see the stock program display on the LED matrix.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

To connect the board to the IDE, click the dropdown in the top toolbar and select the Select Other Board and Port button. A popup box will appear.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

In the search box under boards, type in Uno R4. Two options will appear under the boards column. Select the correct board you are using, either the Minima or the WiFi. On the ports side of the popup, there should be a couple of options appearing. One will be either COM3 or COM4 and then another COM port with a higher number. An easy test is to unplug the board and plug it back in to see which COM port your board is, especially if you have multiple devices plugged into your computer. Once the correct port is selected, select the OK button.

For the first sketch, I will show you how to write the code so that the Uno will print Hello World to the Serial Monitor. This is a very simple sketch, however, if you talk with almost anyone that has worked with coding microcontrollers, they have used either the Blink sketch or the Hello World sketch to get started.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

As you can see above, there are only 3 lines of code that need to be added to get this sketch working.

The first line, Serial.begin(115200), sets the baud rate or speed of communication of the Uno. This gets placed into the void setup() section of the code. The Setup section will only run one time when the board starts. In this case, the communication speed only needs to be set one time.

The next lines of code are added under the void loop section. The Loop section of code continues to loop over and over again until the code is stopped or the board unplugged.

The command Serial.println(“Hello World”); will print the words in quotation marks to the serial monitor, in this case, it will print Hello World. The delay function, delay(1000);, adds a 1000 millisecond(1 second) delay before looping back to the beginning of the loop section.

Now that the code has been entered into the IDE, click the verify (checkmark) button to verify that the code doesn’t have any errors. Once the code has been verified, click the upload (arrow pointing to the right) to upload the code to the board. Once the upload is complete, click the serial monitor button which is in the top right corner (looks like a magnifying glass looking at a line of dots), or press Control>Shift>M to open it. The monitor should start populating with Hello World repeating itself once every second.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

To take the first idea to the next level, I thought it would be fun to take the Hello World idea up a notch and print Hello World to the LED Matrix on the board. In doing a bit of research into how this would be accomplished I came across the LED Matrix page on the Arduino Learn library Using the Arduino UNO R4 WiFi LED Matrix | Arduino Documentation. In reviewing this page, I first noticed that I had to install the ArduinoGraphics library. To do this, I clicked on the libraries button which is third from the top on the left side of the screen of the IDE. In the search bar, I then searched for Arduino Graphics. Once the correct library was found, shown in the picture below, I clicked on the install button.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

Once the ArduinoGraphics library was installed, I started looking into what code was needed to make this work.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

To start, I included both the ArduinoGraphics library and the Arduino_LED_Matrix library. This will allow me to be able to use all of the predefined functions that are already built in these libraries. To learn more about the ArduinoGraphics library, please visit this Arduino Reference page for it ArduinoGraphics - Arduino Reference. The second library, Arduino_LED_Matrix, is a bit harder to find information about. The easiest way I found to learn more about it was to dig into the examples that load under the LED Matrix examples that load when the Uno R4 board packages are installed.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

As shown in the photo above, there are 5 examples to check out. I typically like to run each of these examples and then try to figure out the inner workings of each. This helps me twofold as I learn how to use the examples and they typically inspire new ideas to try with this.

Getting back to the code, The next thing that needed to be set up was to set up the Serial Baud rate for debugging or monitoring, as well as initialize the Matrix to begin.

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

QuickStart Guide: Getting Your Arduino Uno R4 Minima or WiFi Running

In the loop portion of the code, there are a few things that need to be set up in order for this to function correctly.

  • Matrix.beginDraw() - starts the drawing process of the matrix
  • Matrix.stroke(0xFFFFFF) – sets the color of the text and graphics to white(although in testing I’m not sure if this line is even needed)
  • matrix.textScrollSpeed(30) – sets the scrolling speed of the text by setting how many milliseconds each position is displayed
  • const chart text[] – Sets the text that will scroll across the screen. In my case I added a couple spaces before and after the text to create a bit of a buffer before the text starts over
  • Matrix.textFont() – specifies which font to use (in this case it is a 5x7 pixel font)
  • Matrix.beginText(0, 1, 0xFFFFFF) – sets the starting point to 0,1 and sets the color to white
  • matrix.println(text) – prints the text on the screen
  • matrix.endText(SCROLL_LEFT) – sets the direction that the text will scroll
  • Matrix.endDraw() – stops the drawing process for this loop

If you would like to take this code and make it your own, here is all the code. I did change the message that prints out from Hello World. For a bit of fun, try changing the scroll speed and direction and really make it your own.

 

Copy Code
‎#include "ArduinoGraphics.h" ‎‎// calling the Arduino ‎Graphics library
‎#include ‎‎"Arduino_LED_Matrix.h"// ‎calling the Arduino LED ‎Matrix library

ArduinoLEDMatrix ‎matrix;  //creates an ‎instance of the ‎ArduinoLEDMatrix class;‎

void setup() {‎
‎  // put your setup code ‎here, to run once:‎
Serial.begin(115200);‎
matrix.begin();‎

‎}‎

void loop() {‎
‎  // put your main code ‎here, to run repeatedly:‎
‎  matrix.beginDraw();‎
‎  matrix.stroke(0xFFFFFF);‎
‎  matrix.textScrollSpeed(30)‎‎;‎

‎  const char text[]= ‎‎"   Hello from Travis ";‎
‎  matrix.textFont(Font_5x7);‎
‎  matrix.beginText(0, 1, ‎‎0xFFFFF);‎
‎  matrix.println(text);‎
‎  matrix.endText(SCROLL_LEFT‎);‎

‎  matrix.endDraw();‎
‎}‎
制造商零件编号 ABX00080
ARDUINO UNO R4 MINIMA
Arduino
¥162.80
Details
制造商零件编号 ABX00087
ARDUINO UNO R4 WIFI
Arduino
¥223.85
Details
制造商零件编号 AKX00069
PLUG AND MAKE KIT BREADBOARD-FRE
Arduino
¥711.12
Details
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum