` 本帖最后由 lustao 于 2019-5-22 15:25 编辑
根据上周 麦昆小车-红外遥控小车试验1程序,
遥控器的键值:
- 电源 47
- 主页 189
- 菜单 23
- 上 183
- 下 55
- 左 87
- 右 215
- ok 135
- 音量- 199
- 音量+ 143
- 返回(退出)125
- 1 121
- 2 185
- 3 57
- 4 217
- 5 89
- 6 153
- 7 25
- 8 233
- 9 105
- 0 249
- 功能键 95
- 删除 241
- vod点播 223
- 设置 63
- 静音 175
- 电视机部分:
- 电源 112
- TV/AV 176
- 音量- 48
- 音量+ 208
复制代码
用的上传模式。
产生的自动生成码
- #include
- #include
- #include
- #include
- #include
- #include
- double df_state;
- double my_variable;
- double df_red;
- double df_green;
- double df_blue;
- DFRobot_URM10 urm10(1,2);
- Maqueen_Motor motor;
- DFRobot_NeoPixel rgb_display_15;
- DFROBOT_IRremote_Receive remote(16);
- void _8D85_58F0_6CE2();
- void df_state();
- void _663E_793A();
- void _8D85_58F0_6CE2()
- {
- if ((((urm10.getDistanceCM()) <= 20) || ((urm10.getDistanceCM()) == 0))) {
- motor.motorStop(motor.LEFT);
- motor.motorStop(motor.RIGHT);
- MMatrix.show(MMatrix.SKULL);
- df_state = (((int)df_state) % ((int)2));
- digitalWrite(12,LOW);
- digitalWrite(8,LOW);
- MMatrix.print((urm10.getDistanceCM()));
- delay(10);
- }
- }
- void df_state()
- {
- if ((df_state >= 64)) {
- motor.motorRun(motor.LEFT,motor.CW,my_variable);
- motor.motorRun(motor.RIGHT,motor.CW,0);
- }
- else {
- if ((df_state >= 32)) {
- motor.motorRun(motor.LEFT,motor.CW,0);
- motor.motorRun(motor.RIGHT,motor.CW,my_variable);
- }
- else {
- if ((df_state >= 16)) {
- motor.motorRun(motor.LEFT,motor.CCW,my_variable);
- motor.motorRun(motor.RIGHT,motor.CCW,my_variable);
- }
- else {
- if ((df_state >= 8)) {
- motor.motorRun(motor.LEFT,motor.CW,my_variable);
- motor.motorRun(motor.RIGHT,motor.CW,my_variable);
- }
- else {
- }
- }
- }
- }
- }
- void _663E_793A()
- {
- if (((((int)df_state) % ((int)2)) == 1)) {
- rgb_display_15.setRangeColor(0, 0, rgb_display_15.rgbToColor(round(df_red), round(df_green), round(df_blue)));
- rgb_display_15.setRangeColor(1, 1, rgb_display_15.rgbToColor(round(df_red), round(df_green), round(df_blue)));
- rgb_display_15.setRangeColor(2, 2, rgb_display_15.rgbToColor(round(df_red), round(df_green), round(df_blue)));
- rgb_display_15.setRangeColor(3, 3, rgb_display_15.rgbToColor(round(df_red), round(df_green), round(df_blue)));
- delay(50);
- }
- else {
- rgb_display_15.clear();
- }
- }
- void onIRReceive(uint8_t data_IR)
- {
- if ((data_IR > 0)) {
- Serial.begin(9600);
- Serial.println(data_IR);
- if ((data_IR == 183)) {
- motor.motorRun(motor.LEFT,motor.CW,my_variable);
- motor.motorRun(motor.RIGHT,motor.CW,my_variable);
- MMatrix.show(MMatrix.ARROW_N);
- df_state = ((((int)df_state) % ((int)2))+8);
- digitalWrite(12,LOW);
- digitalWrite(8,LOW);
- }
- if ((data_IR == 55)) {
- motor.motorRun(motor.LEFT,motor.CCW,my_variable);
- motor.motorRun(motor.RIGHT,motor.CCW,my_variable);
- MMatrix.show(MMatrix.ARROW_S);
- df_state = ((((int)df_state) % ((int)2))+16);
- digitalWrite(12,LOW);
- digitalWrite(8,LOW);
- }
- if ((data_IR == 87)) {
- motor.motorRun(motor.LEFT,motor.CW,0);
- motor.motorRun(motor.RIGHT,motor.CW,my_variable);
- MMatrix.show(MMatrix.ARROW_E);
- digitalWrite(8,HIGH);
- df_state = ((((int)df_state) % ((int)2))+32);
- digitalWrite(12,LOW);
- }
- if ((data_IR == 215)) {
- motor.motorRun(motor.LEFT,motor.CW,my_variable);
- motor.motorRun(motor.RIGHT,motor.CW,0);
- MMatrix.show(MMatrix.ARROW_W);
- digitalWrite(12,HIGH);
- df_state = ((((int)df_state) % ((int)2))+64);
- digitalWrite(8,LOW);
- }
- if ((data_IR == 135)) {
- motor.motorStop(motor.LEFT);
- motor.motorStop(motor.RIGHT);
- MMatrix.show(MMatrix.ASLEEP);
- df_state = (((int)df_state) % ((int)2));
- digitalWrite(12,LOW);
- digitalWrite(8,LOW);
- }
- if ((data_IR == 199)) {
- my_variable = my_variable - 1;
- MMatrix.print(my_variable);
- df_state();
- }
- if ((data_IR == 143)) {
- my_variable = my_variable + 1;
- MMatrix.print(my_variable);
- df_state();
- }
- if ((data_IR == 189)) {
- if (((((int)df_state) % ((int)2)) == 1)) {
- df_state = df_state - 1;
- }
- else {
- df_state = df_state + 1;
- }
- }
- if ((data_IR == 47)) {
- df_state = 0;
- motor.motorStop(motor.LEFT);
- motor.motorStop(motor.RIGHT);
- MMatrix.show(MMatrix.ASLEEP);
- digitalWrite(12,LOW);
- digitalWrite(8,LOW);
- }
- if ((data_IR == 121)) {
- MSound.playTone(0, 262, BEAT_1);
- }
- if ((data_IR == 185)) {
- MSound.playTone(0, 294, BEAT_1);
- }
- if ((data_IR == 57)) {
- MSound.playTone(0, 330, BEAT_1);
- }
- if ((data_IR == 217)) {
- MSound.playTone(0, 349, BEAT_1);
- }
- if ((data_IR == 89)) {
- MSound.playTone(0, 392, BEAT_1);
- }
- if ((data_IR == 153)) {
- MSound.playTone(0, 440, BEAT_1);
- }
- if ((data_IR == 25)) {
- MSound.playTone(0, 494, BEAT_1);
- }
- if ((data_IR == 233)) {
- MSound.playTone(0, 523, BEAT_1);
- }
- if ((data_IR == 249)) {
- MSound.play(0, BIRTHDAY, Once);
- }
- }
- }
- void setup() {
- rgb_display_15.begin(15, 4, 255);
- remote.begin();
- remote.setCallback(onIRReceive);
- my_variable = 20;
- df_state = 0;
- rgb_display_15.clear();
- }
- void loop() {
- if (((((int)df_state) % ((int)2)) == 1)) {
- while (1) {
- df_red = 0;
- df_green = 0;
- df_blue = 255;
- for (int count = 0; count < 255; count++) {
- df_red = df_red + 1;
- df_blue = df_blue - 1;
- _663E_793A();
- _8D85_58F0_6CE2();
- }
- for (int count = 0; count < 255; count++) {
- df_green = df_green + 1;
- df_red = df_red - 1;
- _663E_793A();
- _8D85_58F0_6CE2();
- }
- for (int count = 0; count < 255; count++) {
- df_blue = df_blue + 1;
- df_green = df_green - 1;
- _663E_793A();
- _8D85_58F0_6CE2();
- }
- }
- }
- else {
- _8D85_58F0_6CE2();
- }
- }
复制代码
红外遥控:
电源键 47(all关)
主页键 189(下彩灯变换)
车行驶:
上 183
下 55
左 87
右 215
ok 135(car stop)
加减速:
音量- 199(car speed+1)
音量+ 143(car speed-1)
music (1234567和高音1):
1 121
2 185
3 57
4 217
5 89
6 153
7 25
8 233
0 249(music brithday)
按0播放brithday,第二次死机。
`
0
|
|
|
|