这是我们本次的作业:《遥控手臂》。
单词 | Word |
---|---|
机械手臂 | mechanical arm |
魔方 | rubik's cube |
自由度 | degree of freedom |
这是它的代码:
#include <Servo.h>
#include <IRremote.h>
long mr_shen;
Servo servo_9
IRrecv_6(6);
decode_results results_6;
void setup(){
Serial.begin(9600);
servo_9.attach(9);
irrecv_6.enableIRIn();
}
void loop(){
if (irrecv_6.decode(&results_6)){
mr_shen=results_6.value;
String type="UNKNOWN";
String typelist[14]={"UNKNOWN","NEC","SONY","RC5","RC6","DISH","SHARP","PANASONIC","JVC","SANYO","MITSUBISHI","SUMSUNG","LG","WHNTER"};
if(results_6.decode_type>=1&&result_6.decode_type<=13){
type=typelist[results_6.decode_type];
}
Serial.print("IR TYPE:"+type+" ");
Serial.println(mr_shen);
servo_9.write(90);
delay(0);
irrecv_6.resume();
} else {
servo_9.write(0);
delay(0);
}
delay(3000);
}
谢谢观看!