【麦昆试用】遥控小车
<div class='showpostmsg'>这个程序使用了两个microbit,一个控制麦昆运行,一个用作遥控器,通过加速度传感器来控制小车前进后退。两个microbit之间通过无线方式通信。小车控制
from microbit import *
import radio
radio.on()
radio.config(length=32, channel=18, power=7, address=0x20190523, group=8)
def md(d):
if abs(d) > 20: return abs(d)
else: return 0
def Moto(M1=0, M2=0):
m = bytearray(3)
m = 0
m =
m =
i2c.write(16, m)
m = 2
m =
m =
i2c.write(16, m)
while 1:
try:
rd = radio.receive()
if rd != None:
#print(rd)
d = rd.split(',')
#print(d)
if d == 'MQMT':
d1 = int(d)
d2 = int(d)
display.clear()
#display.set_pixel(x, y, 9)
Moto(d1, d2)
sleep(10)
except Exception as e:
Moto(0, 0)
print(e)
遥控器
**** Hidden Message *****
此内容由EEWORLD论坛网友dcexpert原创,如需转载或用于商业用途需征得作者同意并注明出处
</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> {:1_107:}{:1_107:} <p>遥控器的看看学习呀 </p>
<p>学习</p>
<p>想看看有没有红外的那种micropython包</p>
<table cellpadding="0" cellspacing="0" id="pid2878554" summary="pid2878554">
<tbody>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<p>遥控器的看看学习呀 </p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
页:
[1]