Home > other >  Bosses, infrared sensor control steering operation code: what happened
Bosses, infrared sensor control steering operation code: what happened

Time:09-27

Bosses, infrared sensor control steering operation code how make!

What I want effect:
Have a sensor (6) after receiving information (high) turn another motive issued orders to make it stop after turn 180 degrees, after the sensors do not accept signal (low), transfer motivation according to the return direction 180 back in the same place to stop,

Tools:
The human body infrared sensors: hc - sr505
Arduino uno r3 -
Steering gear

The following is my current program, the old can not meet the desired effect

#include
Int irSensorPin=6;
Bool irSensorOutput;
Int duojiPin=9;
Servo myservo;

Int pos=0;

Void setup () {
PinMode (irSensorPin, INPUT);

Myservo. Attach (duojiPin);
Serial.begin(9600);
}

Void loop () {
IrSensorOutput=digitalRead (irSensorPin);
If (irSensorOutput==HIGH) {Serial. Println (" IR Motion Sensor OUTPUT: HIGH. ");

For (pos=0; Pos & lt;=180; Pos +=1) {
Myservo. Write (pos);

Delay (15);
}} else {
Serial. Println (" IR Motion Sensor OUTPUT: LOW. "); For (pos=180; Pos & gt;=0; Pos -=1) {
Myservo. Write (pos);

Delay (15);
}
}
delay(100);
}

CodePudding user response:

Never done this, but have a motor control, controlled step mode, consider the best deceleration problem!