Multiple Arduinos

I’ve done some research into using two Arduinos but all the examples use a potentiometer and LED. Should it still work if I use an ultrasonic sensor on the primary board and a gearmotor on the secondary?

Sure, as long as the motor doesn’t require more power than the arduino can provide