Coding

The Senate Bus moves around its own special track, made up of a black line road, and four different Senate Bus stops: Schneider Center at Wellesley, Harvard University in Cambridge, the Kresge stop at MIT (represented by the familiar Mass Ave landmark, Lobby 7, on our track), and the SAE fraternity on Beacon Street. As the true Senate Bus does, the route commences at the Wellesley College Schneider Center and then brings our Lego Wellesley students (who were, in reality, Lego spacemen!) to Hahvahd, to Kresge, to Beacon St. and finally back home to Schneider . The bus crashes into each stop (per the real Senate Bus), and puts itself in reverse to back up. It beeps to warn anyone that might be in its way to move or they will be run over. Finally, after backing up and turning towards the current stop, it lets off 1-2 Wellesley students by flinging them towards the buildings (per the real Senate Bus--except this one actually *stops*!)

For the Senate Bus to actually navigate along the "road", it uses reflectance sensors which deterimne the amount of light reflected by the surface that it is placed over; the color black black barely reflects light, whereas white surfaces reflect light. Thus, we programmed the bus to detect a specific threshhold of reflected light that helps it to discriminate whether it is over a black surface or a white surface. We devised two drivers, one sober and one drunk, to follow the line in different manners. The drunk driver is programmed such that when the right sensor senses black, a motor turns on and the entire vehicle turns right. Conversely, when the left sensor senses black, a different motor turns on and the bus turns left. By placing the bus such that it straddles the black road initially, it will always either "see" black in either its right sensor or left sensor. Because the program tells the bus to turn in the direction that it senses the black, the opposite reflectance sensor will inevitably be pulled over the black road, and the bus will turn in the opposite direction; thus, the bus moves in a zig-zag motion, giving it the semblance of being driven under the influence of a drunk driver!!! The sober driver uses the same reflectance sensors, but it can also recognize when it is *straddling* a black line. It turns when it sees black in one of its reflective sensors (it will turn in the direction of the reflectance sensor that is "seeing" black), but when both sensors "see" white, it knows that it is straddling a line, and goes straight (by turning both motors on). Click to see the actual code for how the drunk driver or the sober driver follows the road.

The program randomly determines which driver will be commandeering the bus. So you, as the virtual passenger, never know which driver you are driving with until the bus driver turns on the radio at the beginning of the journey. The sober driver plays "The Wheels on the Bus," while the drunk driver, an admirer of Jam'n 94.5 FM, listens to"What Is Love?" by Haddaway.

When the bus goes along its route, it "encounters" the different stops along the way. In fact, it plows right into them. There is a touch sensor on the front bumper that lets the bus know when it hits a wall. When the bus hits one of the stops, it knows that it is time to let off some passengers. After the front-bumper is hit, it backs up (backup warning beeps included!), turns right, so the door is facing the building, and activates the conveyor belt that lines up the Wellesley students at the door. The motor that kicks them out with a swift boot is then activated and the passengers are flung out of the bus. After the passengers are evacuated from the vehicle, the bus moves along looking for the road again, so it can do the same thing at the next stop, eventually stopping completely once it returns home to Schnieder Center. Click to see the code for backing up and ejecting the passengers!

To see the entire code, click here!

Back to home