|
楼主 |
发表于 2019-9-22 10:00:24
|
显示全部楼层
- /*
- 【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
- 实验一百二十二: BBC microbit micro:bit,bit go,bit club python图形编程开发板
- 项目:点阵屏、环境灯与红外遥控:遥控小车前进、左转、右转,配置了音乐与转向灯
- */
- #include <DFRobot_IRremote_dal.h>
- #include <Maqueen_Motor.h>
- #include <Microbit_Sound.h>
- #include <Microbit_Matrix.h>
- #include <DFRobot_NeoPixel.h>
- DFROBOT_IRremote_Receive remote(16);
- Maqueen_Motor motor;
- const uint8_t bitmap_CC1T[5] = {B01010,B11111,B11111,B01110,B00100};
- DFRobot_NeoPixel rgb_display_15;
- void onIRReceive(uint8_t data_IR)
- {
- if ((data_IR == 157)) {
- motor.motorRun(motor.LEFT,motor.CW,68);
- motor.motorRun(motor.RIGHT,motor.CW,68);
- MSound.play(0, RINGTONE, OnceInBackground);
- MMatrix.show(MMatrix.ARROW_N);
- digitalWrite(12,HIGH);
- digitalWrite(8,HIGH);
- }
- if ((data_IR == 87)) {
- motor.motorStop(motor.LEFT);
- motor.motorStop(motor.RIGHT);
- MSound.play(0, POWER_DOWN, OnceInBackground);
- MMatrix.show(MMatrix.BUTTERFLY);
- digitalWrite(12,LOW);
- digitalWrite(8,LOW);
- }
- if ((data_IR == 221)) {
- motor.motorRun(motor.LEFT,motor.CW,0);
- motor.motorRun(motor.RIGHT,motor.CW,42);
- digitalWrite(12,LOW);
- digitalWrite(8,HIGH);
- MMatrix.show(MMatrix.ARROW_E);
- }
- if ((data_IR == 61)) {
- motor.motorRun(motor.LEFT,motor.CW,40);
- motor.motorRun(motor.RIGHT,motor.CW,0);
- digitalWrite(8,LOW);
- digitalWrite(12,HIGH);
- MMatrix.show(MMatrix.ARROW_W);
- }
- if ((data_IR == 253)) {
- MMatrix.show(bitmap_CC1T);
- delay(1000);
- MMatrix.show(MMatrix.HEART_SMALL);
- }
- if ((data_IR == 151)) {
- MMatrix.show(MMatrix.PACMAN);
- }
- if ((data_IR == 79)) {
- MMatrix.show(MMatrix.TARGET);
- }
- if ((data_IR == 103)) {
- MMatrix.print("hello world");
- }
- }
- void setup() {
- remote.begin();
- remote.setCallback(onIRReceive);
- rgb_display_15.begin(15, 4, 255);
- }
- void loop() {
- rgb_display_15.setRangeColor(0, 0, 0xff0000);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.clear();
- delay(1000);
- rgb_display_15.setRangeColor(0, 0, 0x00ff00);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.clear();
- delay(1000);
- rgb_display_15.setRangeColor(0, 0, 0x0000ff);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.rotate(1);
- delay(1000);
- rgb_display_15.clear();
- }
复制代码 |
|