ECOBOT

An Animated Landscape

Created by Adrian Bockian '09 and Alex French '11 for Robotic Design Studio (PHYS/CS 115), Wintersession 2009.

Home

How EcoBot works

Inspiration

Construction

Code

Exhibition

Creators

Acknowledgments

 

Code

HandyLogo: the first version comprising the waste station, the energy station, and the industry station

Alex wrote this first version of the HandyLogo code, using HandyLogo exclusively. You may notice that some of the code was left undefined. Before filling in all the missing definitions, we realized that we would need more than one HandyBoard because we were using more than four motors, but there were no spare HandyBoards in the lab. We decided to operate the energy station using HandyLogo, and then we began writing code in PicoBlocks for the industry station and the waste station. (See HandyLogo: the second version below.)

HandyLogo preliminary code 1

HandyLogo preliminary code 2

HandyLogo preliminary code 4

HandyLogo preliminary code 5

HandyLogo preliminary code 6

HandyLogo preliminary code 7

HandyLogo preliminary code 8

HandyLogo preliminary code 9

HandyLogo preliminary code 10

HandyLogo preliminary code 11

HandyLogo preliminary code 12

HandyLogo: the second version operating only the energy station

At this point in the code writing process, Adrian began editing the code and rewiting it in different languages. You may notice that "oil-rig-announcement" was deleted from the code since we decided to use Scratch to control EcoBot's sounds. Our code for the energy station remained otherwise unchanged in this second version.

This is how it works. Switch 7, the light switch, turns on motor b, which turns on the light in the log cabin. After 10 seconds, the motor controlling the rotator turns enough to move the oil-rig into position. Half a second later, the oil rig begins running, and it continues until the front panel switch for renewable energy is pressed (switch 8). This is as much as we have seen the energy station perform as of the writing of this page. The following is what we would expect to see after the renewable energy switch is pressed.. After half a second, the windmill will rotate into place, and after another half-second it will begin running. Note that once the half a second necessary to start the functioning of the windmill has elapsed, the HandyBoard will check to see if switch 8, the renewable energy switch, and switch 7, the light switch, are being pressed. If neither of them is still being pressed, the light will turn off, the windmill will stop, and a patch of grass will replace the windmill. As such, the windmill's functioning is level-triggered. The renewable energy switch, switch 8, must be held continually to operate the windmill. On the front panel instructions, the user is not told to continue pressing swtich 8, and in the future we would like to revise the code to make it edge-triggered. Ideally, pressing the light switch a second time would cause the light to go off, the windmill to stop, and the grass to rotate back into place. Alex timed how long it took the oil-rig to rise and fall and how much time the rotator took to move between the oil rig, the windmill, and the grass, yielding the time values written in the code.

 

HandyLogo energy

HandyLogo energy 2

HandyLogo energy 3

PicoBlocks

When we wrote the code in HandyLogo for the industry station, we had not yet ruled out using nitrates to simulate polluting the lake water and cleaning it up. By the time we were working with PicoBlocks, we had received a suggestion from Lily, one of our classmates. She suggested using a container of water with a light under it that would change color when the water was supposed to become polluted. Otherwise, we retained our original concept when we rewrote our code in PicoBlocks.

This is how the factory station works using PicoBlocks. A light sensor detects that the factory has been placed on the board. Then the light beneath the lake changes from blue to orange, and the motor controlling the deer's track turns long enough for the deer to move away from the lake. When a touch sensor is pressed, representing the reduction in pollutants released by the factory, the light beneath the lake changes back to blue and the deer circulates back to the edge of the lake. Once we had completed the deer track, we decided where the deer should stop and start and then we timed its movement. We determined that the motor needed to turn 65 seconds to move the deer from its starting position to a point more than halfway around the track and then 40 seconds to bring it back.

Picoblock for industry

As for the waste station, there is a difference between the HandyLogo code and the PicoBlock below. Whereas with HandyLogo, we were planning to place a sensor in the recycling bin and have it control the rising of the trees, we decided ultimately to rely entirely on one touch sensor placed in the trash bin. The trees are held up by a motor running "this way." When waste placed in the trash bin activates the touch sensor inside the trash bin, the motor will turn in the reverse direction for 15 seconds, lowering the trees for 15 seconds. The waste station evolved to become more simplistic than we originally imagined. When the user removes the waste from the trash and places it in the recycling bin, their environmentally sustainable choice actually does not register with EcoBot. Minor detail. In this one instance, EcoBot is sustainable regardless of the user's actions.

Picoblock for waste

Scratch

Adrian wrote the following code to control sounds accompanying environmental changes in EcoBot. The sounds are controlled by three light sensors placed on the board.

At the waste station, there is a light sensor inside the trash bin which detects when waste has been placed there. As long as this sensor detects darkness, the sound of trees cutting will play. Although this recording will not repeat, it is long enough that the user will probably have removed the trash from the bin before the recording has finished.

At the energy station, a light sensor in the log cabin detects when the light has been turned on in the house. The following announcement, read by Alex and recorded on Adrian's laptop, will play: "Attention, nation, due to increased demand for electricity, our only option is to drill for oil in the national park."

At the industry station, when the factory is placed on the board, a light sensor connected to the Scratch board detects it. Factory sounds play as long as the factory is on the light sensor. Once again, the recording will not repeat, but the recording is long enough that this should not diminish the effect.

scratch code for factory, trees, announcement

Finally, when none of the above three sounds are being played, Scratch plays nature sounds as a default.

scratch code for nature 1scratch code for nature 2

Scratch worked for us exactly as described above, however at the exhibition, few people probably noticed the sounds because there was so much ambient noise at the event. We would attach additional speakers to Adrian's laptop for future demonstrations.