3.6 Follow Your Hand 2

In the 3.4 Follow Your Hand project only the ultrasonic module is used, it can only follow your hand forward.

In this project, we use 2 IR obstacle avoidance modules at the same time, so that the car can follow your hand left or right.

Required Components

In this project, we need the following components.

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

3 in 1 Starter Kit

380+

3 in 1 Starter Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

SunFounder R3 Board

BUY

L298N Module

BUY

TT Motor

-

Ultrasonic Module

BUY

Obstacle Avoidance Module

BUY

Build the Circuit

Connect the ultrasonic module and the two IR obstacle avoidance modules at the same time.

The wiring between the ultrasonic and the R3 board is as follows.

Ultrasonic Module

R3 Board

Vcc

5V

Trig

3

Echo

4

Gnd

GND

The wiring of the 2 IR obstacle avoidance modules to the R3 board is as follows.

Left IR Module

R3 Board

OUT

8

GND

GND

VCC

5V

Right IR Module

R3 Board

OUT

7

GND

GND

VCC

5V

../../_images/car_avoid_ultrasonic1.jpg

Programming

The effect to be achieved by this project is as follows

  • Ultrasonic detects your hand about 5-10cm in front and let the car follow.

  • The infrared module on the left detects your hand and turns to the left.

  • The right IR module detects your hand and turns to the right.

1. Create a block

Create blocks that allow the car to move forward, turn left, turn right and stop.

../../_images/6_follow2_1.png

2. Follow to move forward

Read the ultrasonic value and if your hand is detected at a distance of 5-10cm, then let the car follow.

../../_images/6_follow2_2.png

3. Follow to turn left and right

Read the values of the left and right IR modules.

  • If the left IR module detects your hand, turn left.

  • If the right IR module detects your hand, turn right.

  • If neither IR module and ultrasonic module detect your hand, make the car stop.

../../_images/6_follow2_3.png