A-B On-Off
In the first part of this challenge, we had to create a program which uses two different switches to toggle the two motors on and off. When switch 1 is pressed, motor a turns on until the button is no longer on. When switch 2 is pressed motor b should turn on until it has stopped being pressed.
This program is just a simple forever loop telling the robot to turn motor a on while switch 1 is being pressed and to have it off when switch one is not pressed and the same for switch 2 and motor b.
A-B Reverse
The second part of this challenge was a bit more difficult. We were to create a program similar to that in the first part, except this time, pressing switch 1 should reverse the direction of motor a every time it is pressed and pressing switch 2 does the same for motor b.
Originally we attempted this program by creating a new block using the writing portion of the PicoBlocks program. We made a block to test if a given value is even or not. The thinking behind this was that we would use a counter to count how many times the button was pressed and if the button had been pressed an odd number of times the motor should turn one way and if the button had been pressed an even number of times the motor should turn the other way. This however, for whatever reason, did not seem to work out, so we decided to use a similar approach to this part of the challenge as well.
This code is composed of two separate, simultaneously run stacks. Both stacks are virtually identical except that one uses switch 1 to control motor a and the other uses switch 2 to control motor b. These codes use "wait until" statements instead of "if" statements because we now want to use level triggered logic instead of edge triggered logic like we used in the first part. In the first part we wanted the motor to remain running for as long as we kept the switch pressed. In this case, however, we want the motor to go in the reverse direction just after a single click of the button instead of holding down the button.
Both of these programs worked well, except the second program seemed to be temperamental.
It seems that Whiney, after working with us for so long and listening to us complain about how it didn't work, became very lazy. He also seemed to develop an attachment to Professor Berg, because a peculiar situation occurred in which, when trying to run the second program, Whiney only seemed to work when Professor Berg was around. To test this theory, we constantly asked Professor Berg to come near and go far away from Whiney. Our suspicions turned out to be true. Whiney has gotten so lazy that he only works when Professor Berg is watching. Either this is just a disdain for his friends (a.k.a us who have had "so much faith" in him this whole time) or it is sheer laziness in which he only works when he absolutely has to. Either way, the cause for this temperamental behavior remains a mystery.
----Sigh----
Farewell Whiney!!!
No comments:
Post a Comment