Posts

Showing posts from July, 2018

Insertion Sort algorithm in depth with C++

Image
We can visualize an example of the Insertion Sort algorithm with an array of integers that needs to be sorted. In this case we will set the start position as the blue arrow that is located at index 1. Where we will compare 3 < 7 . If this is true, then we will have to swap these with eachother. Now, this is true for 3 < 7 so we will swap

Queue data structure with C++

Image
Contrary to a Stack , the queue data structure uses FIFO (First In, First Out). In order to explain this concept, we can imagine some people standing in a line. Where person A (Blue) is the first one to enter the line. A will then be the last to go out from the line. Person F (Grey) is the last to enter, so the person will therefor be the last to get out from the line. With other words, with FIFO the first element in a sequence will also be the first to go out of the sequence. Creating a queue class with C++ we will need some functions, such as enqueue(), dequeue(), queue_size(), is_empty() and display(). So let's make a class with those.

Simple Arduino PIN lock with LCD Display

Image
I thought it would be fun to build something that looked like a smart lock for a door. With an Arduino Uno, three buttons being 1, 2 and 3 along with a buzzer, some LED diodes and a microservo I was able to make a simple mechanism that can both grant- and deny access. The servo will rotate on a valid PIN and keep an angle for X seconds (See gif underneath). Furthermore, if the PIN code is incorrect the servo won't rotate. Here's a gif of the system in action. Starting out with recreating the project I will be using TinkerCad to illustrate some of the parts. We can start out with the attachment of the three buttons to a breadboard, along with some LED diodes to indicate a button being pressed. From there we can add the buzzer (Piezo speaker in this image) and one more LED diode which will both activate when the PIN code is correct. This is when the system should grant access and the servo rotate. Now we can connect the servo to the breadboard.