×

如何制作声控LED面罩

消耗积分:0 | 格式:zip | 大小:0.13 MB | 2023-02-08

莫循虎

分享资料个

描述

声控 LED 面罩连接说明

防范措施:

制作声控灯面罩时,威廉希尔官方网站 焊接时请小心,以免被焊机烫伤皮肤!请正确连接威廉希尔官方网站 并选择好的充电宝。威廉希尔官方网站 短路和电流输入不良可能引起事故!声光口罩是要贴在脸上的,所以口罩面料的选择很重要,请选择防火面料!最后请小孩子在大人陪同下制作。

所需工具:

焊接

烙铁

织物胶水或针线包

护目镜

胶带

可选有用的东西

热缩管(电工胶带可以在紧要关头使用,但热缩管很好)

数字万用表(用于确保您的连接正确且电子设备正常工作)

焊垫

阿杜诺纳米

零件

LED 矩阵 8x8 WS2812B

麦克风max4466

阿杜诺纳米

330Ω电阻

24号线

热收缩

5V移动电源

KCD1开关

物理威廉希尔官方网站 图

pYYBAGPi9cKAX-_AAAEqlM0xoTo894.jpg
 

威廉希尔官方网站 连接

LED 矩阵 8x8 WS2812B DIN 引脚------------330Ω 电阻

330Ω电阻------------Arduino Nano D6 Pin

max4466麦克风VCCpin--------------Arduino Nano 5V Pin

max4466麦克风GNDpin------------Arduino Nano GND Pin

max4466 麦克风输出引脚--------------Arduino Nano A7 引脚

LED 矩阵 8x8 WS2812B 5V 引脚------------ Arduino Nano VIN 引脚

LED 矩阵 8x8 WS2812B GND pin------------ Arduino Nano GND pin

KCD1开关------------ Arduino Nano D12引脚

Arduino Nano GNDpin------------ KCD1开关

生产

1、安装库文件:打开Arduino开发软件中的“工具”-“库管理器”,然后搜索Adafruit_NeoPixel、Adafruit_NeoMatrix、Adafruit_GFX_Library,然后安装这三个库

 
 
 
pYYBAGPi9cmAQEqtAACKAIoKfCo077.jpg
 
1 / 3
 

 

poYBAGPi9d6AaO9rAADsD50NL_0410.jpg
 

 

pYYBAGPi9eiAcak3AADnMAqIiMc181.jpg
 

2.选择开发板为Arduino Nano,这个是选对了。

poYBAGPi9eyACIYJAADPVGUteTM704.jpg
 

3.选择处理器为ATmega328P(Old Bootloader),这个是选对了。

pYYBAGPi9e-AKKU-AACiuYH7CGI972.jpg
 

4、然后选择端口,这个端口要和你在设备管理器里看到的一样,这样你就可以把代码烧进开发板了。

pYYBAGPi9fKAUMZoAACH7IeHIIs039.jpg
 

 

 

#include #include #include #define lengthof(A) ((sizeof((A))/sizeof((A)[0])))
#define button 12
int oldstate=HIGH;
const PROGMEM uint8_t mouth_0[8][8] = {
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,6,6,6,6,0,0}, 
   {0,6,6,6,6,6,6,0},
   {6,6,0,0,0,0,6,6},
   {6,0,0,0,0,0,0,6},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_4[8][8] = {
   {0,0,7,7,7,7,0,0},
   {0,7,0,0,0,0,7,0},
   {7,0,0,0,0,0,0,7},
   {7,0,0,0,0,0,0,7},
   {7,0,0,0,0,0,0,7},
   {7,0,0,0,0,0,0,7},
   {0,7,0,0,0,0,7,0},
   {0,0,7,7,7,7,0,0}
};
const PROGMEM uint8_t mouth_3[8][8] = {
   {0,0,0,0,0,0,0,0},
   {0,0,7,7,7,7,0,0},
   {0,7,0,0,0,0,7,0},
   {7,0,0,0,0,0,0,7},
   {7,0,0,0,0,0,0,7},
   {0,7,0,0,0,0,7,0},
   {0,0,7,7,7,7,0,0},
   {0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_2[8][8] = {
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,7,7,7,7,7,7,0},
   {7,0,0,0,0,0,0,7},
   {7,0,0,0,0,0,0,7},
   {0,7,7,7,7,7,7,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_1[8][8] = {
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,7,7,0,0,0},
   {7,7,7,0,0,7,7,7},
   {7,7,7,0,0,7,7,7},
   {0,0,0,7,7,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t mouth_smile[8][8] = {
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {2,0,0,0,0,0,0,2},
   {2,2,0,0,0,0,2,2},
   {0,2,2,2,2,2,2,0},
   {0,0,2,2,2,2,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0}
};
const PROGMEM uint8_t off_set[8][8] = {
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0}
};
uint16_t palette[8] = {};
Adafruit_NeoMatrix matrix1 = Adafruit_NeoMatrix(8, 8, 6,
 NEO_MATRIX_BOTTOM     + NEO_MATRIX_RIGHT +
 NEO_MATRIX_ROWS    + NEO_MATRIX_ZIGZAG,
 NEO_GRB            + NEO_KHZ800);
Adafruit_NeoMatrix matrix2 = Adafruit_NeoMatrix(8, 8, 7,
 NEO_MATRIX_BOTTOM     + NEO_MATRIX_RIGHT +
 NEO_MATRIX_ROWS    + NEO_MATRIX_ZIGZAG,
 NEO_GRB            + NEO_KHZ800);
Adafruit_NeoMatrix matrix3 = Adafruit_NeoMatrix(8, 8, 2,
 NEO_MATRIX_BOTTOM     + NEO_MATRIX_RIGHT +
 NEO_MATRIX_ROWS    + NEO_MATRIX_ZIGZAG,
 NEO_GRB            + NEO_KHZ800); 
Adafruit_NeoMatrix matrix4 = Adafruit_NeoMatrix(8, 8, 0,
 NEO_MATRIX_BOTTOM     + NEO_MATRIX_RIGHT +
 NEO_MATRIX_ROWS    + NEO_MATRIX_ZIGZAG,
 NEO_GRB            + NEO_KHZ800); 
void drawImage(short image_addr){
   for(int x = 0; x<8; x++){
       for(int y = 0; y<8; y++){
           uint8_t index = pgm_read_byte(image_addr+x+y*8);
           matrix1.drawPixel(x, y, palette[index]); 
           matrix2.drawPixel(x, y, palette[index]); 
           matrix3.drawPixel(x, y, palette[index]);  
           matrix4.drawPixel(x, y, palette[index]);
       }
   }
   matrix1.show();
   matrix2.show();
   matrix3.show();
   matrix4.show();
}
int pop_detection = 0;
bool smiling = false;
unsigned long smiletimer = 0;
unsigned long last_face = 0;
float vol = 0;
const uint16_t samples = 128;
void setup() {
   Serial.begin(9600);
   matrix1.begin();
   matrix2.begin();
   matrix3.begin();
   matrix4.begin();
   palette[0] = matrix4.Color(0,0,0);        //No color
// palette[1] = matrix.Color(0,0,255);       //blue
   palette[2] = matrix3.Color(255,0,255);    //purple
// palette[3] = matrix.Color(0,255,0);       //green
// palette[4] = matrix.Color(255,255,255);   //white
// palette[5] = matrix.Color(255,0,0);       //red
   palette[6] = matrix1.Color(0,255,255);    //yellow 
   palette[7] = matrix2.Color(255,255,0);    //cyan
  pinMode(button,INPUT_PULLUP);
}
void loop() {
   int newstate=digitalRead(button);
     if(newstate == LOW){
   float nvol = 0;
   int previous_peak = -1;
   for (int i = 0; i       auto analog = analogRead(A7);
       auto micline = abs(analog - 512);
       nvol = max(micline, nvol);
   }
   vol = (nvol + 1.0*vol)/2.0;
   if(nvol > 200){
       pop_detection += 1;
       if(pop_detection > 5) {
           smiling = false;
           last_face = millis();
       }
   } else {
       if(pop_detection > 0 && pop_detection <= 5) {
           if(millis() > last_face + 500){
               smiling = true;
               smiletimer = millis() + 2000;
           }
       }
       pop_detection = 0;
   }
   if(millis() > smiletimer) 
   smiling = false;
     if(smiling){
       drawImage(mouth_smile);
   } else if(vol < 200){
       drawImage(mouth_0);
   } else if(vol < 250 && vol > 200){
       drawImage(mouth_1); 
   } else if(vol < 350 && vol > 250){
       drawImage(mouth_2);
   } else if(vol < 450 && vol > 350){
       drawImage(mouth_3);
   } else {
       drawImage(mouth_4);
       }
     }
     else
     {
       drawImage(off_set);
     }
}
;>

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !

'+ '

'+ '

'+ ''+ '
'+ ''+ ''+ '
'+ ''+ '' ); $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code ==5){ $(pop_this).attr('href',"/login/index.html"); return false } if(data.code == 2){ //跳转到VIP升级页面 window.location.href="//m.obk20.com/vip/index?aid=" + webid return false } //是会员 if (data.code > 0) { $('body').append(htmlSetNormalDownload); var getWidth=$("#poplayer").width(); $("#poplayer").css("margin-left","-"+getWidth/2+"px"); $('#tips').html(data.msg) $('.download_confirm').click(function(){ $('#dialog').remove(); }) } else { var down_url = $('#vipdownload').attr('data-url'); isBindAnalysisForm(pop_this, down_url, 1) } }); }); //是否开通VIP $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code == 2 || data.code ==5){ //跳转到VIP升级页面 $('#vipdownload>span').text("开通VIP 免费下载") return false }else{ // 待续费 if(data.code == 3) { vipExpiredInfo.ifVipExpired = true vipExpiredInfo.vipExpiredDate = data.data.endoftime } $('#vipdownload .icon-vip-tips').remove() $('#vipdownload>span').text("VIP免积分下载") } }); }).on("click",".download_cancel",function(){ $('#dialog').remove(); }) var setWeixinShare={};//定义默认的微信分享信息,页面如果要自定义分享,直接更改此变量即可 if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'){ var d={ title:'如何制作声控LED面罩',//标题 desc:$('[name=description]').attr("content"), //描述 imgUrl:'https://'+location.host+'/static/images/ele-logo.png',// 分享图标,默认是logo link:'',//链接 type:'',// 分享类型,music、video或link,不填默认为link dataUrl:'',//如果type是music或video,则要提供数据链接,默认为空 success:'', // 用户确认分享后执行的回调函数 cancel:''// 用户取消分享后执行的回调函数 } setWeixinShare=$.extend(d,setWeixinShare); $.ajax({ url:"//www.obk20.com/app/wechat/index.php?s=Home/ShareConfig/index", data:"share_url="+encodeURIComponent(location.href)+"&format=jsonp&domain=m", type:'get', dataType:'jsonp', success:function(res){ if(res.status!="successed"){ return false; } $.getScript('https://res.wx.qq.com/open/js/jweixin-1.0.0.js',function(result,status){ if(status!="success"){ return false; } var getWxCfg=res.data; wx.config({ //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId:getWxCfg.appId, // 必填,公众号的唯一标识 timestamp:getWxCfg.timestamp, // 必填,生成签名的时间戳 nonceStr:getWxCfg.nonceStr, // 必填,生成签名的随机串 signature:getWxCfg.signature,// 必填,签名,见附录1 jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function(){ //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 wx.onMenuShareTimeline({ title: setWeixinShare.title, // 分享标题 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享给朋友”按钮点击状态及自定义分享内容接口 wx.onMenuShareAppMessage({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 type: setWeixinShare.type, // 分享类型,music、video或link,不填默认为link dataUrl: setWeixinShare.dataUrl, // 如果type是music或video,则要提供数据链接,默认为空 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ”按钮点击状态及自定义分享内容接口 wx.onMenuShareQQ({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 wx.onMenuShareWeibo({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 wx.onMenuShareQZone({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); }); }); } }); } function openX_ad(posterid, htmlid, width, height) { if ($(htmlid).length > 0) { var randomnumber = Math.random(); var now_url = encodeURIComponent(window.location.href); var ga = document.createElement('iframe'); ga.src = 'https://www1.elecfans.com/www/delivery/myafr.php?target=_blank&cb=' + randomnumber + '&zoneid=' + posterid+'&prefer='+now_url; ga.width = width; ga.height = height; ga.frameBorder = 0; ga.scrolling = 'no'; var s = $(htmlid).append(ga); } } openX_ad(828, '#berry-300', 300, 250);