dirty 发表于 2025-1-21 00:01

【嘉楠K230开发板】点亮LED

<div class='showpostmsg'><p>&nbsp; &nbsp; &nbsp; 本篇讲述驱动板载LED闪烁。</p>

<p><strong><span style="color:#0000ff;">一.硬件原理</span></strong></p>

<p>&nbsp; &nbsp; &nbsp; 开发板板载一颗蓝色LED,硬件原理如下,高电平点亮。</p>

<div style="text-align: center;"></div>

<p><strong><span style="color:#0000ff;">二.程序代码</span></strong></p>

<p>&nbsp; &nbsp; &nbsp; CanMV IDE K230使用MicroPython开发,这里驱动代码如下:</p>

<pre>
<code>from machine import Pin #导入Pin模块
from machine import FPIOA
import time

#将GPIO52配置为普通GPIO
fpioa = FPIOA()
fpioa.set_function(52,FPIOA.GPIO52)

LED=Pin(52,Pin.OUT) #构建led对象,GPIO52,输出

while True:
    LED.value(1) #点亮LED,也可以使用led.on()
    time.sleep(1) #1s
    LED.value(0)
    time.sleep(1) #1s</code></pre>

<p><strong><span style="color:#0000ff;">三.运行测试与固化</span></strong></p>

<p>1.运行测试</p>

<p>&nbsp; &nbsp; &nbsp; 开发板接上USB Type C并上电,打开CanMV IDE K230,连接上开发板后点如下图绿色三角按钮运行</p>

<div style="text-align: center;"></div>

<p>2.程序固化</p>

<p>&nbsp; &nbsp; &nbsp; 直接在IDE里面运行功能代码是保存在开发板的RAM(内存)里面,方便调试,但断电后丢失。需要开发板断电后再上电能运行相关程序,则如下操作,将代码以main.py发送到开发板</p>

<div style="text-align: center;"></div>

<p>3.程序固化后,关掉IDE,开发板上电,可以看到蓝色LED灯闪烁,效果如下:</p>

<p>00008b8ffa113ce63d4487fe4388bfe5</p>

<p>&nbsp; &nbsp; &nbsp; 至此,使用IDE固化程序,实现开发板驱动点灯功能。</p>

<p>&nbsp;</p>
</div><script>                                        var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                                       
                                        if(parseInt(discuz_uid)==0){
                                                                                                (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                        }                </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>

懒猫爱飞 发表于 2025-1-22 14:56

加油

dirty 发表于 2025-1-22 16:13

懒猫爱飞 发表于 2025-1-22 14:56
加油

<p>好的</p>
页: [1]
查看完整版本: 【嘉楠K230开发板】点亮LED