Ai-M61-32S开发环境搭建MacOS+Arduino IDE

[复制链接]
查看1063 | 回复3 | 2023-11-25 13:50:39 | 显示全部楼层 |阅读模式
MacOS 13以上可以直接使用这个方法:


1. 安装Arduino 2.2.1,下载地址: https://downloads.arduino.cc/ard ... est_macOS_64bit.dmg

2. 安装完成后,点击File->Preferences->Additional Boards Manager URLs,输入:
  1. https://github.com/bouffalolab/arduino-bouffalo/releases/latest/download/package_bouffalolab_index.json
复制代码


                               
登录/注册后可看大图



3. 在左面的BOARD MANAGER搜索BL618,然后安装

                               
登录/注册后可看大图

这步需要比较长的时间,大家要有耐心。

4. Tools选择board是BL618G0:

                               
登录/注册后可看大图



5. 输入代码:
  1. #include <WiFi.h>

  2. int button_gpio = 33;
  3. int button_state = false;

  4. // Change the WIFI ssid and WIFI password below to yours.
  5. char *ssid     = "your-ssid";
  6. char *password = "your-password";

  7. void setup() {
  8.     Serial.begin(2000000);
  9.     delay(10);

  10.     // set LED output
  11.     pinMode(LED_BUILTIN, OUTPUT);
  12.     // set input key SW3
  13.     pinMode(button_gpio, INPUT_PULLUP);

  14.     WiFi.begin(ssid, password);
  15.     // Will try for about 10 seconds (20x 500ms)
  16.     int tryDelay = 500;
  17.     int numberOfTries = 20;

  18.     while (true) {
  19.         switch(WiFi.status()) {
  20.             case WL_NO_SSID_AVAIL:
  21.                 Serial.println("[WiFi] SSID not found");
  22.                 break;
  23.             case WL_CONNECT_FAILED:
  24.                 Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
  25.                 return;
  26.                 break;
  27.             case WL_CONNECTION_LOST:
  28.                 Serial.println("[WiFi] Connection was lost");
  29.                 break;
  30.             case WL_SCAN_COMPLETED:
  31.                 Serial.println("[WiFi] Scan is completed");
  32.                 break;
  33.             case WL_DISCONNECTED:
  34.                 Serial.println("[WiFi] WiFi is disconnected");
  35.                 break;
  36.             case WL_CONNECTED:
  37.                 Serial.println("[WiFi] WiFi is connected!");
  38.                 Serial.print("[WiFi] IP address: ");
  39.                 // Serial.println(WiFi.localIP());
  40.                 return;
  41.                 break;
  42.             default:
  43.                 Serial.print("[WiFi] WiFi Status: ");
  44.                 Serial.println(WiFi.status());
  45.                 break;
  46.         }
  47.         delay(tryDelay);

  48.         if(numberOfTries <= 0){
  49.           Serial.print("[WiFi] Failed to connect to WiFi!");
  50.           // Use disconnect function to force stop trying to connect
  51.           WiFi.disconnect();
  52.           return;
  53.         } else {
  54.           numberOfTries--;
  55.         }
  56.     }

  57. }

  58. void loop() {

  59.     button_state = digitalRead(button_gpio);
  60.     if (button_state == LOW)
  61.     {
  62.         // Disconnect from WiFi
  63.         Serial.println("[WiFi] Disconnecting from WiFi!");
  64.         // This function will disconnect and turn off the WiFi (NVS WiFi data is kept)
  65.         WiFi.disconnect();
  66.         Serial.println("[WiFi] Disconnected from WiFi!");
  67.         delay(1000);
  68.     }

  69.     digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  70.     delay(1000);
  71.     digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  72.     delay(1000);

  73. }
复制代码


6. 使用编译:

                               
登录/注册后可看大图



如果是MacOS 13以下的话,需要自己手工编译xuantie-gnu-toolchain才行。注意需要大小写区分的驱动器才能进行编译。


本帖被以下淘专辑推荐:

回复

使用道具 举报

沈夜 | 2023-11-25 14:34:17 | 显示全部楼层
非常实用的建议,我会尝试一下,谢谢你!
回复 支持 反对

使用道具 举报

ai_mcu | 2023-11-25 18:39:06 | 显示全部楼层
活动时间已经截至,发帖可不用带【申请板子】标签,分享技术可在其他板块发帖,之前的帖子已经统计送审
明天总会更好
回复 支持 反对

使用道具 举报

496199544 | 2023-11-26 15:44:14 | 显示全部楼层
学习
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则