### Week 12 Journal

Sicheng Yang - Sun 31 May 2020, 11:47 pm *Modified: Fri 12 June 2020, 5:33 pm*

This week is a relatively busy week. In fact, the coming poster and demo of thesis took up most of my time, so this week is mainly based on retrospective reflection and small improvements.

# Work done

## Hardware

This week I went to buy a 9v battery connector. After the test, its performance is very good, it reduces the most weight on the helmets and improves the experience. In fact, I wanted to use a 9v battery in the early stage. But when I searched it on Jaycar, I thought that this is a special connector to Arduino, so I never found it. But I recently realised that it is a universal type, and finally found it in the area of the battery compartment. Really unexpected.

In the studio we discussed how to do the final work to make the prototype look complete. I realised it was time to cover the bare lines and Arduino. In the end I got advice from tutor to use beanie (new term learned). This is a good solution and adds a bit of vitality to the prototype. But considering that my prototype needs to be exercised and the cap needs additional fixation, maybe I can try the clip.

## Software

I have reworked the method of median filtering for audio and pace. At the beginning, I chose the average sampling method, that is, sampling a hundred times and averaging all the data. This method has been greatly improved compared to direct sampling at the beginning. Therefore, I always think that this method is very effective. After getting the idea of median filtering from Clay, I still insisted on calculating the average value at the end, but the range was narrowed down to 10 values around the median， as shown below.

`int arr[100]; int sum = 0; for (int i = 0; i < 100; i++) // get sensor data 100 times { arr[i] = analogRead(soundPin); // data from analog in } sort(arr); // bubble sort, see below sum = 0; for (int i = 45; i < 55; i++) // get 10 values in middle { sum += arr[i]; } sum /= 10;`

As a result, the sampling values I obtained are still not very stable. Until recently, I suddenly realized that it is meaningless to perform average sampling in median filtering. So I removed the process and used the real median directly.

`int arr[100]; int sum = 0; for (int i = 0; i < 100; i++) { arr[i] = analogRead(soundPin); } sort(arr); sum = (arr[49] + arr[50]) / 2;`

In fact, the direct use of the median has brought a huge improvement in the accuracy of sampling, especially for the calculation of pace. This is very unexpected to me.

But I also learned an important lesson from it. Sometimes giving up some inefficient solutions can bring more improvement to the project. If I'm unwilling to abandon it completely just because I have put effort on it, it will bring more restrictions.

But in any case, this is very exciting for me. It solves a long-standing problem for me, but it is so simple.

# Work to do

Next week I will concentrate on making the portfolio, including the videos and content showing in it. Now I have made a skeleton website, and then I only need to fill in the content. Could be easy.

But I also want to try some new tricks, such as using multiple fixed backgrounds to create sliding effects. It depends on time.