THE CODE: to find-road-and-cross waituntil [switchb] a, on thisway waituntil [sensora < 50] a, rd wait 5 off b, onfor 2 wait 2 rd repeat 2 [ onfor 6 wait 2 rd] onfor 2 wait 5 a, rd on wait 30 waituntil [sensora < 50] wait 60 a, off wait 10 repeat 70 [b, onfor 1 rd] end
|
This first part of the code is stored in the cricket imbedded into the base of the chicken. It contols the walking and head-moving functions, as well as the sensing of the road. What does it all mean.... Though most of the code is pretty self explanatory, it may help to know a few things: "a" refers to motor a, which powers the motor that makes the chicken walk. "switchb" is a touch switch that you press to begin the chicken's program "sensora" is the reflective sensor that can find the black line "b" is motor b, which is connected to the chicken's head also, rd means reverse direction , and the numbers after the inequalites designate thresholds that I want the sensor looking for
|
THE CODE: to lay-egg-and-flap waituntil [sensorb > 120] repeat 20 [a, onfor 1 rd] a, onfor 4 thatway b, onfor 3 thisway onfor 4 thatway] end
|
The second part of the code is stored in the cricket visible on the chicken's back. It controls the laying of eggs and the flapping of wings. What does it all mean.... "sensorb" is the reflective sensor mounted underneath the egg hatch. When it is activated (meaning, it senses something has happened to put the sensor reading within the given range), the rest of the program can commence. It is the start button for this second part of the chicken's behavior. "a" is the motor that controls the wing motion "b" is the motor that controls the opening and closing of the hatch |