|
电机程序:
[mw_shl_code=c,true]void setup() {
// put your setup code here, to run once:
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
analogWrite(A0, 200);
analogWrite(A1, 200);
}
[/mw_shl_code]
注:6789为数字IO口,A0A1为模拟IO口。
红外程序:
[mw_shl_code=c,true]int num = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
num = analogRead(A3);
if (num > 500)
Serial.println("no people");
else
Serial.println("people");
delay(100);
}[/mw_shl_code]
|
|