User:MTomaselli/ENES-100/Bicycle Turn Signal

Week 7 Narrative
This week Heidi Schultz, Richard Rickert, and myself took over the Bicycle Turn Signal Project. Typically, picking up a project mid-way through completion, our first step was assimilate ourselves with the material we are working with. After some brief conversation and a little bit of research we found that we continue using the Super Bright 5mm LED Lights and the 5mm LED Holders. My next step was to figure out if there are limiting specifications that can impact the implementation and further design of the Turn Signal. Luckily, Sparkfun keeps a rather detailed website and I was able to find Specs for the LEDs & Holder. These were surprisingly useful in that I was able to find the maximum and minimum operating temperature for the Super Bright 5mm LED Lights, which turns out to be roughly 235(degF) and -40(degF). Obviously, designing and marketing this project in the United States, I knew that the operating temperature restraint wouldn't be an issue.

With the project scope already clearly laid out from the previous group I knew what was needed to make this project a completed an operable product. With my background in coding I tasked myself with creating the code that would run the Bicycle Turn Signal. The first that I needed to address was the /Operations Order of Operations/ that was going to take place during the user implementation phase. This consisted of pushing the right push button to turn the right signal on, pushing the left push button to turn the left signal on, and a deceleration to turn the break bar on. The code I have posted below is the first iteration and rough draft of what I needed to implement for the Turn Signal to operate properly (it does not include the deceleration feature yet).

Week 8 Narrative
This week I continued to update my code to properly accommodate all of the necessary functionality. The first mistake I noticed, which is evident in the code I wrote above, was that in each of my "While Functions" I stated that if the push buttons equalled a 0 or 1 they would then relay that information to the Arduino which would then turn the proper LED's on and off. This is actually not the correct way to determine if the push button was pushed or not. In C++, or Arduino coding, the proper way to read if a push button is pushed is to check to see whether the input is equal to "HIGH" of "LOW." After I luckily figured that out I was now tasked to change my code, utilizing the HIGH/LOW commands to check which push button(s) are being pushed for a given bicycle turn. I then decided that I would need to check my code and ensure that it properly works for all of my possible circumstances. So I went ahead and hooked up an Arduino to my computer which was then connected to a breadboard with three LED's and two push buttons. Once I had everything powered up and the code uploaded onto the Arduino I noticed that there something wrong with what I was expecting to see. I saw that the LED's were blinking regardless of what push buttons I had pressed, or not, for that matter. It was at this instance that I realized it was most likely my "Nested Do-While Loops" which were causing the issue. As I have minimal exposure in the algorithmic way to write a Do-While Loop I decided that I was going to instead simply use "Individual While Loops." Since C++ automatically forces you to create a "Loop Function" I used this to my benefit and wrote Individual While Loops inside of the Arduino Loop Function. This ensures that the Loop Function would constantly run through, checking, and ultimately running, which ever While Loop was "correct." This can all be seen in the code I have written below. However, it still lacks to necessary coding utilizing the Accelerometer to turn the Break Bar on.

UPDATED CODE ___ USE

Week 9 Narrative
As Heidi was getting ready to 3D print the LED housing and Richard was nearly completed with soldering jumper wires to each of the 36 LEDs, I wanted to finalize my code and finally incorporate the accelerometer. My week began on Monday while I was sitting in my ENES100 class where I was discussing the use of the accelerometer with my group. As I have never used one before I was expressing my concerns with writing the code to utilize it's functionality. I began searching the internet for example code scripts written for an accelerometer, which was ultimately useless. With my frustration growing, one of the other professors for ENES 100 was sitting in my class finishing up one of his projects, he overheard my complaint about the lack of example codes. By the grace of god, he actually just used an accelerometer in his project and had his code online for me to view. After discussing the in's and out's of the accelerometer and how it properly used I was able to figure out exactly how I would incorporate it into the Bicycle Turn Signal Project. I found out that the accelerometer I was going to use initializes to a fixed value when it turned on, called the "rest value." The rest value is dependent on what type of accelerometer you use as well as what computer you are using. This actually is not an issue and ultimately doesn't matter what this exact value is, as long as you account for it you can determine you acceleration (in my case deceleration). So what I needed to do was when my code is uploaded to the Arduino I needed to read the accelerometer and store it's rest value as a variable. Then with this value stored I can write an "If Statement" which simply states that if the current value of your acceleration (when you are physically riding the bike) subtracted from the rest value is a negative number, then you are in fact decelerating which would in-so-facto turn on the Break Bar. The code below is the final code, which will be used to operate the Bicycle Turn Signal.

This is the MOST UP-TO-DATE CODE INCLUDING THE ACCELEROMETER -- May need to add Flashing LED Code into each of the IF STATEMENTS

Week 10 Narrative
In the final week of the Bicycle Turn Signal Project I wanted to ensure that my code was going to work by building a small prototype of what the turn signal would look like. So what I did was wire 4 LEDs to a breadboard and connect them to digital output pins on the Arduino. What I first did was connect the Arduino ground pin the negative side of the breadboard. I then went ahead and connected a jumper wire to 4 different digital output pins on the Arduino. This was so that I can address each of the 4 LEDs individually by implementing While Loops in my code. This was done by connecting wires from pins 13, 12, 11, and 10 to a different row on the breadboard. I then connected 4 LEDs to each of the 4 rows in which the wires were connected to, with the positive (longer leg) next to the jumper wire and the negative (shorter leg) into the negative side of the breadboard. After I finished this I went ahead and uploaded my code to the Arduino. The Break Bar light up and stayed on, which was actually a good sign because the code is designed for that to happen. But this really didn't show me that the rest of code was working properly. It was at this time that my first issue of the week arose.

I was having some serious problems getting my switches to work. My first troubleshooting attempt was to connect one of the switches with alligator clips to the breadboard. This didn't work out as well as I had hoped. I then decided I was going to try to connect the switch to a different breadboard and write a quick test code to see if I had the wiring connection correct. In the end, this attempt was basically useless but it did lead me to my next try at fixing the switch. I noticed that the switch was wired correct but it appeared that the wiring was not secure enough. So this led me to believe that I needed to solder jumper wires to the switch. After spending quite a bit of time attempting to solder the switch, I had absolutely no success and gave up.

I still needed to test my code and make sure all of the possibilities worked out the way I wanted. So what I decided to do was to manually input the values for the switches and the accelerometer. After I tried every possible outcome, I was pleased to see that my code worked exactly how I wanted it to. This left me with only figuring out how to wire the two switches and the accelerometer to the breadboard. Once, I have that figured and complete the Bicycle Turn Signal Project will be effectively complete and ready for live user testing.