所有分类
主题 主题
平台 平台
我的工作台
userHead
注册时间 [[userInfo.create_time]]
创造力 [[userInfo.creativity]]
[[userInfo.remark]]
[[d.project_title]]
articleThumb
[[d.material_name]]
timelineThumb
进入工作台
折叠
所有分类 我的工作台
展开
定时炸弹
云天 云天 2019-09-05 21:38:45
2
0
简单

先上图片

projectImage
projectImage
projectImage

演示视频

材料清单 材料清单
1x
DFRobot Leonardo & Xbee R3
1x
IO 传感器扩展板 V7.1
1x
Gravity: UART MP3语音模块
1x
Gravity:URM09-模拟量超声波测距传感器
1x
无源音箱小喇叭 (8Ω3W)
1x
充电宝
4x
纸筒
1x
MAX7219LED点阵

Max7219点阵的制作,请参考本人的另一个帖子:MAX7219LED点阵显示双位数字 http://mc.dfrobot.com.cn/thread-297748-1-1.html

倒计时结束时的爆炸音,是通过UART MP3语音模块实现。它的维库:http://wiki.dfrobot.com.cn/index.php?title=(SKU:DFR0534)Voice_Module

projectImage

接线图

projectImage
代码 代码
	                    					#include <DFRobot_LedControl.h>
#include <DFRobot_SerialMp3.h>
#include <SoftwareSerial.h>
#include <DFRobot_Ultrasonic.h>

DFRobot_Ultrasonic ultraA0;
DFRobot_SerialMp3 serialMp3;
SoftwareSerial softSerialserialMp3(10, 11);
DFRobot_LedControl max7219(3, 5, 4);
const byte LedArray_left[10][8] = {{B00000000,B11100000,B10100000,B10100000,B10100000,B10100000,B10100000,B11100000},
{B00000000,B11000000,B01000000,B01000000,B01000000,B01000000,B01000000,B11100000},
{B00000000,B11100000,B00100000,B00100000,B11100000,B10000000,B10000000,B11100000},
{B00000000,B11100000,B00100000,B00100000,B11100000,B00100000,B00100000,B11100000},
{B00000000,B10100000,B10100000,B10100000,B11100000,B00100000,B00100000,B00100000},
{B00000000,B11100000,B10000000,B10000000,B11100000,B00100000,B00100000,B11100000},
{B00000000,B11100000,B10000000,B10000000,B11100000,B10100000,B10100000,B11100000},
{B00000000,B11100000,B00100000,B00100000,B00100000,B00100000,B00100000,B00100000},
{B00000000,B11100000,B10100000,B10100000,B11100000,B10100000,B10100000,B11100000},
{B00000000,B11100000,B10100000,B10100000,B11100000,B00100000,B00100000,B11100000}};
const byte LedArray_right[10][8] = {{B00000000,B00000111,B00000101,B00000101,B00000101,B00000101,B00000101,B00000111},
{B00000000,B00000110,B00000010,B00000010,B00000010,B00000010,B00000010,B00000111},
{B00000000,B00000111,B00000001,B00000001,B00000111,B00000100,B00000100,B00000111},
{B00000000,B00000111,B00000001,B00000001,B00000111,B00000001,B00000001,B00000111},
{B00000000,B00000101,B00000101,B00000101,B00000111,B00000001,B00000001,B00000001},
{B00000000,B00000111,B00000100,B00000100,B00000111,B00000001,B00000001,B00000111},
{B00000000,B00000111,B00000100,B00000100,B00000111,B00000101,B00000101,B00000111},
{B00000000,B00000111,B00000001,B00000001,B00000001,B00000001,B00000001,B00000001},
{B00000000,B00000111,B00000101,B00000101,B00000111,B00000101,B00000101,B00000111},
{B00000000,B00000111,B00000101,B00000101,B00000111,B00000001,B00000001,B00000111}};
byte show[]={B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
void setup() {
	max7219.begin();
	serialMp3.begin(&softSerialserialMp3);
	serialMp3.play();
	serialMp3.volume(99);
	ultraA0.begin(A0);
}

void loop() {
    int m;
    int n;
   
  	for (int i = 99; i> 0;i--) {
	   	
	   	m=int(i/10);
	   	n=i%10;
		 	for (int j = 0; j < 8; j++) {
	       show[j]=LedArray_left[m][j]+LedArray_right[n][j];
      }
	   	max7219.show(show);
	   	if ((ultraA0.getDistanceCm() < 50)) {
	   	  break;
	     }
	    else{
  	  delay(1000);
	    }
    }
   	serialMp3.playList(17);
   	delay(5000);
}

	                    				
Makelog作者原创文章,未经授权禁止转载。
2
0
评论
[[c.user_name]] [[c.create_time]]
[[c.parent_comment.count]]
[[c.comment_content]]