Home / Codes / Implementing Bubble Sort in AVR/Arduino

Implementing Bubble Sort in AVR/Arduino

This is a short note on implementing the Bubble Sort algorithm on the AVR and Arduino microcontrollers. Bubble sort or sinking sort is one of the many sorting algorithms. In this algorithm,  a list is repeatedly read where each line is compared to adjacent elements and swaps them if they are in the wrong order. The algorithm stops once all the elements in the list is sorted.

In the application note, the subroutine “bubble” sorts up to 224 bytes of SRAM data which is the SRAM area that can be reached by the lower eight bits of a pointer.

The flow-chart of the bubble sort algorithm is shown:

bubble sort algorithm

Source code: Download

Full application note:

doc0939

Check Also

moving average filter

Implementing an 8-point Moving Average Filter

If you read sensors using microcontrollers before, you have dealt with data that is always …

Leave a Reply

Your email address will not be published. Required fields are marked *