Optically driven small machines have such features as easily miniaturized in fabrication and as controlled by optical energy which is supplied in wireless. We reported an optically controlled machine which moves like a caterpillar on the basis of photo-thermal effect. It consists of two parts: a body (made of shape memory alloys and springs) and feet (made of magnets and temperature-sensitive ferrite). The feet can stick to the floor due to magnetic force and therefore it has such ability as ascending a slope, and ultimately it succeeded in climbing the vertical wall and moved underneath the ceiling. A lot of applications are expected to this kind of machines. However, if the purpose is restricted to the movement inside the pipe, the structure can be more simplified. This time we propose a miniaturized machine which moves like a mole or an earthworm. It mainly consists of a shape-memory alloy and a spring, and nylon wires are attached at the head and tail. When the machine moves in the pipe, these wires cause difference in friction. force between the forward movement and the backward movement Stretching and contracting are brought by photo-thermal effect of the body part consisting of the alloy and spring. This machine (total length 12 mm, diameter 2.5 mm except the nylon feet) is placed in a vinyl tube ( inner diameter 4 turn, wall thickness I mm) and controlled by a light beam outside from a halogen lamp (150 W, 100 V). In room temperature the alloy is kept stretched by the spring, but, when the beam is projected onto the body from outside, it contracts to the original size because photo-thermal effect brings much larger force than the stretching force due to the spring. Then the wires at the head prevent moving back and the wires at the tail easily slip. This fact brings forward movement of the machine. At this moment 25 seconds are necessary for one cycle of movement and the moving speed is 2.6 mm/cycle.