Contributed by WangChong, curated by Ai-Thinker
Introduction
Arduino is an open-source embedded hardware platform that lets users build interactive embedded projects. The Arduino IDE provides a large number of ready-made library functions for users to search and use; with these library functions, developers can quickly verify the MCU's peripheral resources and the peripherals of corresponding communication protocols. The main purpose of this tutorial is to let even a beginner who has never used the Arduino IDE quickly get started with Arduino and learn to use the Arduino API. The Ai-Thinker Ai-M61-32S-Kit also provides Arduino support. Next, I will build the Arduino development environment based on the Ai-M61-32S-Kit from scratch in a few steps. I guarantee beginners can learn it with just their hands — if you can't learn it, you can come chop me!
Arduino Installation and Deployment
Operation Steps
We can visit the Arduino IDE download page directly through the link above.
There are three installation methods: the first is installing with the .exe file, the second with .MSI, and the third is downloading a compressed archive. In this tutorial, we use the .exe method.
After clicking, the page asks whether you want to donate to Arduino; click Just download (as shown below).
The next page asks whether you want to subscribe to Arduino news by email (not recommended). If you subscribe, enter your email and click Subscribe && Download; I clicked Just download.

Open the downloaded Arduino IDE and agree to the license agreement.
Choose to install for all users or just for yourself (I chose for myself).
Click Next, choose the installation directory, then click Install.
Wait for the Arduino IDE installation to complete.

Open the Arduino IDE and select File >> Preferences in the top-left corner.
In Preferences, under Additional Boards Manager URLs, enter the following address and click OK:
Additionally, here is the official Arduino GitHub repository for BL618.
Click Boards Manager on the left, search for BL618, and install it.
Due to network restrictions this may take some time. Below is the interface after BL618 is successfully installed.

Connecting and configuring the Ai-M61-32S-Kit in the Arduino IDE
Operation Steps (continued)
First open the Device Manager on your computer. The steps are: Right-click My Computer and select Device Manager
Find Ports in the Device Manager and open it

Connect the Ai-M61-32S-Kit to the PC and observe the port change. At this time, port 24 is the M61-32S communication port

Select the M61-32S port in the Arduino main interface

Search for and select BL618G0 Board. The completed configuration is shown in the figure below

Using the M61-32S to light an LED (BLINK) So how do we use Arduino functions to light the LED on the M61 board? First, we need to check the M61 schematic for the corresponding LED ports.
According to the schematic, the Red LED is on IO12, Blue on IO15, and Green on IO14. The LED is common cathode (GND connected together). So we just need to give the corresponding LED PIN a high level to light the LED.
Check the official Arduino API on how to operate IO. What we need to use here is the digitalWrite API.
The configuration and detailed method description are as follows.
So we learn that to light an LED, first set pinMode to output mode, then call digitalWrite to write HIGH or LOW to the corresponding PIN, controlling the LED on/off.
Since we want to see an LED blink effect, we also need an appropriate delay so the blink frequency is perceptible to the human eye. In the Arduino API, under the Time module, we can find a function called delay. Its main purpose is to pause the current program for the specified number of milliseconds.
The core code is as follows:
The core code is as follows:
void setup() {
// initialize IO15 as output mode
pinMode(15, OUTPUT);
}
void loop() {
// turn on the blue LED
digitalWrite(15, HIGH);
// sleep for 1 second
delay(1000);
// turn off the blue LED
digitalWrite(15, LOW);
// sleep for 1 second
delay(1000);
}Compile, upload and flash: In the Arduino IDE main interface, click the button below to compile the code. During compilation, the M61-32S board must first enter flash mode. The specific steps are:
Operation Steps (continued)
Click the upload button
Press the board’s Boot button and then the Reset button, holding for about one second
Release to complete the handshake, and flashing begins
Expected result: The blue LED blinks at 1-second intervals.
Troubleshooting:
Note: as of the publishing date, only the blue LED of the RGB can be lit without modifying the Arduino library code.
The reason is that PIN12 and PIN14 are defined as ADC.
You can refer to the following post to solve it:
How to fix Arduino not being able to light the RGB LED of the Ai-M61-32S board
Green and red LED lighting examples:

Have questions?
For other questions, please visit the unified discussion area: Ai-Thinker Discussions

