回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

定时炸弹 简单

头像 云天 2019.09.05 1525 1

先上图片

project-image
project-image
project-image

演示视频

材料清单

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

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

倒计时结束时的爆炸音,是通过UART MP3语音模块实现。它的维库:https://wiki.dfrobot.com.cn/_SKU_DFR0534_Voice_Module

project-image

接线图

project-image
代码
#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);
}

评论

user-avatar
  • 橘子一只awa

    橘子一只awa2022.05.08

    看着有点吓人

    0