Our project utilizes the board and LEDs to create a system of gesture controlled lights which respond to actions by changing to a certain color. The user shall hold the board upright in their hand and make gestures such as swing their hand right, left, up and down. Each of these actions changes the LED color creating an almost disco like effect. Importantly, our processor looks for sudden movements and does not change the color if the board is moving at a constant speed. By connecting the board to a strip of 60 LEDs we have simulated a real life installation of our project which could be mounted to a bodysuit responding to body movements such as dance steps.
Our project begins with making use of the accelerometer onboard and processing the data recieved. A significant change in acceleration in any axis will be detected as movement in that particular direction which will be used to trigger the lights in the color decided. This comprises the majority of the logic in terms of controlling the LED colors, but to actually flash them we wil utilize the daisy chain of LEDs on the existing external board. We will solder the LED strip to the external board and extend the logic which we already have from the previous labs.
Our code can be broken down into 2 parts. We use the SDK example provided in MCUExpresso to process the data from the accelerometer on our board. The provided code lets us access the peripheral but it only processes the x, y, and z readings for a pre defined number of times. However, when we run our code in realtime we want the accelerometer data to be read and processed continuously, so we utilize the timer and the pitIRQhandler to do this. The timer counts down a fixed amount of time after which an interrupt is triggered, which is handled by the function which comprises most of our essential code. When the interrupt is triggered, the accelerometer x, y, and z values are read using which we compute the magnitude of the acceleration vector. Then we compare the magnitude with the same from the last reading and if a large enough difference is detected, we compare the x, y, and z values with the previous readings of the same to see which axis has the largest change. Based on this information, we change the color of the LEDs. To assign LED colors we create arrays that have BRG values to encode the color that we want to see on the LEDs. Finally, to actually change the LED color we use the functions provided from previous labs.
Testing and debugging was an essential part of our project, because some of the elements of our project required fine tuning. The magnitude change threshold had to be calibrated based on brute force testing with various values till a suitable result was achieved. Similarly, the timer value also had to be experimented with because too small a value led to flickering in the LEDs which made colors indistinguishable, while too large a value led to delayed LED change in response to movement.
Debugging was a major portion of our development process because dealing with the accelerometer data processing code required handling minute details of the code which would lead to unexpected behaviour in our project. One of the issues that we spent quite some time debugging was actually a very trivial issue that bothered us; we would try to print out the magnitude of the acceleration vector but the console would remain blank and we kept trying different ways of doing the same computation to check if the type cast was an issue. However, finally we realized that the magnitude was being computed correctly and we could see the value in the variables tab.
Our team prioritised efficient and effective communication right from the start for which we established a communication platform over a group chat application. We discussed that we had a pleasant experience exercising peer programming in our lab development processes, so we decided to implement it here as well. After collaborative brainstorming sessions which involved in-depth discussions of our algorithm to achieve the desired result, we delved into porgramming the actual project. We decided on regular meeting times and all coding was done in the presence of all members with everyone taking turns at typing on a single laptop, after which we would push the code to GitHub. The only work delegation that we did was testing and debugging which we did at our own time.
The accelerometer data processing code is from SDK examples provided by MCUExpresso.
https://youtu.be/ZxTFjVv9V5c