Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRremote.h>
- Rspeedd = getDistance(degreesRight, 'R'); // detection distance on right side
- delay(delay_time); // waiting for servo motor to be stable
- // if left distance greater than right
- if (Lspeedd > Rspeedd) {
- directionn = Lgo; // go left
- }
- if (Lspeedd <= Rspeedd) {//if left distance less than right
- directionn = Rgo; //go right
- }
- if (Lspeedd < 15 && Rspeedd < 15) { //if distance less 10mm both right and left
- directionn = Bgo; //go back
- }
- if (SM == HIGH) {//middle sensor in black area
- if (SL == LOW & SR == HIGH) {//left sensor in black area, right sensor in white, turn left
- left(0);
- }
- else if (SR == LOW & SL == HIGH) {//left white, right black, run right
- right(0);
- }
- else { // left and right both in white, go straight
- advance(0);
- }
- }
- // middle sensor in white area
- else {
- if (SL == LOW & SR == HIGH) { // left black ,right white, turn left
- left(0);
- }
- else if (SR == LOW & SL == HIGH) {
- right(0);
- }
- else { //left and right both in white, stop
- stopp(0);
- }
- }
- stopPressed = stopCommandPressed();
- if (stopPressed) {
- break;
- }
Add Comment
Please, Sign In to add comment