Thursday, May 14, 2015

Final Project Part 5

The Code

Make a code that turns the LED on the blue side of the mat when the children sit on the blue mat and turns on the LED on the red side of the mat when the children sit on the red mat.

Beginning Steps

Before we started writing the code, we looked at some past code that was similar to what we wanted to write. We looked at the SOS code because it included functions we wanted to implement in our final code.




Code Part 1:

Our initial code read the state of the button. If the both buttons on one side of the mat were pressed, then the LED on that side would turn on for two seconds and off for one second. The same would happen if both the buttons were pressed on the other side of the mat. If the buttons were not pressed, the LED would be off. The LED turned off for a short time in this code because we wanted to make sure the code was functioning like we wanted. If the mat were implemented in a real classroom, the LED would turn off for 10-15 minutes, about the time of a typical group time. This way the mat would not be a distraction for the children when they are supposed to be listening to the teacher

Final Code:
We changed the code so that the LEDS would blink in a pattern, instead of only turning on when the buttons are pressed. We thought this would make the mats a bit more exciting and get the children to go to group time.  The short1, short2, long1, and long2, functions show the amount of time the led would be on and then off. Short1 and short2 turn the LED on for half a second and then off for half a second. Long1 and long2 turn the LED on for 1 second and off for half a second. Putting them in sequence in the if statement creates a pattern for the LED. The numbers 1 and 2 correspond to the LEDs on either side of the mat. We wrote the code this way so that it would be easy to change the pattern if someone wanted.


Improvements

1) Make the time the light is turned off longer so it won't interrupt group time.
2) Change the code so when one side of the mat is pressed, the other side can't turn on at all. At this time, if both sides of the mat are pressed at the same time, the lights will alternate turning on after the delay has passed. However, if it was actually implemented, the delay would be much longer and this would not be an issue.
3)Change the code so only one button on one side of the mat needs to be pressed down for the light to go off. At this time, both of the lights on one side need to be pressed down.

Reflection

I had a lot of fun playing around with the code. It was simpler than some of the code I did in the past. It worked really well!

No comments:

Post a Comment