Assignment: Chase the Rabbit

Write a program (sketch) to have your Elegoo search for something that is within 1 meter of itself.

When a "target" is acquired it drives to the target and pushes it.

If the target moves the robot re-acquires and pursues again.


There is a fast rabbit (Jack) and a slower rabbit (Hopalong)
Start with Hopalong and master him first, then go for Jack.


Note: to add randomness:

Put this in void setup:   

randomSeed(analogRead(0));
// so the sequence is different each time

Usage samples:

Forward(random(speed1,160));
// move forward an amount between speed1 and 160

Back(random(speed1,speed2));
// move back an amount between speed1 and speed2

delay(random(300,600));
// delay an amount between 300 and 600




Last modified: Wednesday, 11 March 2026, 9:53 PM
Accessibility

Background Colour Background Colour

Font Face Font Face

Font Kerning Font Kerning

Font Size Font Size

1

Image Visibility Image Visibility

Letter Spacing Letter Spacing

0

Line Height Line Height

1.2

Link Highlight Link Highlight

Text Colour Text Colour