`红外小遥控器
看了前面Altium2的
【麦昆试用体验】4.麦昆小车-红外遥控小车
我也试了下基于MIND+平台 红外小遥控器
用的上传模式。
产生的自动生成码
- #include
- #include
- #include
- double my_variable;
- DFROBOT_IRremote_Receive remote(16);
- Maqueen_Motor motor;
- 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);
- digitalWrite(8,LOW);
- digitalWrite(12,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);
- digitalWrite(8,LOW);
- digitalWrite(12,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);
- }
- 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);
- }
- if ((data_IR == 135)) {
- motor.motorStop(motor.LEFT);
- motor.motorStop(motor.RIGHT);
- MMatrix.show(MMatrix.ASLEEP);
- digitalWrite(8,LOW);
- digitalWrite(12,LOW);
- }
- if ((data_IR == 199)) {
- my_variable = my_variable - 1;
- MMatrix.print(my_variable);
- }
- if ((data_IR == 143)) {
- my_variable = my_variable + 1;
- MMatrix.print(my_variable);
- }
- }
- }
- void setup() {
- remote.begin();
- remote.setCallback(onIRReceive);
- my_variable = 20;
- }
- void loop() {
- }
复制代码
红外小遥控器
小孩很爱玩,下周再加功能。
`
|