【Follow me第二季第4期】点亮led/串口输出
本帖最后由 zsy-s 于 2024-11-27 19:10 编辑<p># 编译环境</p>
<p>arduino封装了好多好多东西。</p>
<p>为了编译,下了手册,模块手册,2040的csdk手册。结果全都用不上。</p>
<p>开启arduino ide。开发板管理器搜索 nano boards(包含rp2040支持),点击安装包。不用翻墙,网速很快,一会安装完成。</p>
<p>rgb led接到WiFi模块上,rp2040通过与wifi模块通信,间接实现了点灯,故还需要一个wifi库支持。</p>
<p>项目-》 导入库-》管理库,搜索 wifinina,点击安装,开发环境搭建完毕。</p>
<p># 点亮led</p>
<p>配置引脚</p>
<pre>
<code class="language-cpp">pinMode(LEDB, OUTPUT);
pinMode(LEDR, OUTPUT);
pinMode(LEDG, OUTPUT);</code></pre>
<p>200ms周期点亮各个颜色的灯</p>
<pre>
<code class="language-cpp">void loop() {
digitalWrite(LEDB, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(LEDR, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LEDG, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(LEDB, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LEDR, HIGH); // turn the LED off by making the voltage LOW
digitalWrite(LEDG, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(LEDB, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LEDR, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LEDG, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
Serial.println("RP2040 hello \n\r ");
}</code></pre>
<p>5c43a0fcd5bcb034ef5f01f92119f415<br />
</p>
<p>通过串口输出日志,效果如下:</p>
<p> </p>
<p># 问题解决</p>
<p>不安装wifi库会出现找不到 fatal error: WiFiNINA.h: No such file or directory</p>
<p>安装wifimnina库,问题消失</p>
<p> </p>
<p># 总结</p>
<p>烧录过程,arduino封装了进入下载+下载固件流程。点亮led的过程,一行代码下去,aeduino提供的接口做了很多活,封的有点多且深。</p>
<p>封装的太好,好处就简单省心,但是但凡烧不了,就得抓瞎。</p>
<p> </p>
<p>串口输出的跟着后边很多的任务 </p>
页:
[1]