Ads

Get STM32 tutorial using HAL at $10 for a limited time!

Monday, April 13, 2015

C# and PostgreSQL Using Npgsql Tutorial 1 - Database Connection

In this tutorial I will share how to make an application with .NET C# that use PostgreSQL database. I am using Visual Studio 2012 for this tutorial. To use Npgsql you must download the library from here. Then add Npgsql.dll and MonoSecurity.dll to project references. References can be found in solution explorer.


After you add Npgsql.dll and MonoSecurity.dll to project references, the next step is to include Npgsql library to your source code using this code:
using Npgsql;
For this tutorial, I will share how to make connection between the application and the database. I will make a class called DatabaseHelper. This class is responsible for handling database functions such as database connection, INSERT, UPDATE, DELETE, SELECT and so on.

Wednesday, April 8, 2015

SQLite Database


SQLite is a relational database management system that written in C programming language. SQLite is stand-alone database (not a client-server database). SQLite is a popular database for local storage in application software. There are many applications that use SQLite for local storage such as web browsers. SQLite is used in web browsers for storing bookmarks, configuration, etc. SQLite is also used in Android for local apps database such as contact, notepad, dictionary, and many more. Another famous product that use SQLite can be found in here.

Tuesday, April 7, 2015

Arduino 16x2 LCD Keypad Shield

In this tutorial, I will share how to use 16x2 LCD Keypad Shield with Arduino Uno. This product is compatible with Arduino LCD library (LiquidCrystal.h). There are 5 buttons in this product (up, down, left, right, and select) that can be used for make project such as display menu items and select them with the buttons.
The 5 buttons in this product are connected to only single pin (A0), so this will save the use of pins. This technique usually called multiplexing. Multiplexing technique can be implemented with multiplexer IC such as 74153. But in this product they use a chain of resistor to do multiplexing. The buttons are connected to a chain of resistors using voltage divider technique. 


Saturday, March 28, 2015

STM32F4 Discovery Tutorial 4 - Configure Clock Using External Crystal (HSE)

From the first tutorial until this tutorial, the system clock that we use is internal RC oscillator (HSI) which the value is 16 MHz. This can be checked by using this simple code:
#include "stm32f4xx.h"

int main(void)
{
    // Update the system core clock variable 
    // according to current clock register value
    SystemCoreClockUpdate();

    while (1);
}
SystemCoreClockUpdate() function is used for update SystemCoreClock variable that store the value of current system clock. To see this variable value, we can go into debug mode. In the Variables tab, do the right click and select Add Global Variables then select the SystemCoreClock variable. After that we can step over the SystemCoreClockUpdate() by using F10. After that line is executed, the SystemCoreClock is updated to 16 MHz in Variables tab.


Sunday, March 22, 2015

Micromouse Robot

I made micromouse robot for my final project. I made this because I was so excited when I first saw this robot. This is the micromouse that make me excited. This micromouse is named Tetra and made by Kato-san. The size is even smaller compared to Tamiya mini 4 WD.


I was playing mini 4 WD when I was elementary school. Tamiya can run fast and turn in the track as it has rollers. When I first saw micromouse, there is a question came to my head. Why and how micromouse can run fast without touching the wall and can also navigate the maze to reach center of the maze? I even ever think that micromouse is controlled by a remote control, but that’s not true. The fact is micromouse has an algorithm to solve the maze. I was so excited to figure out how to make my micromouse, so I make micromouse robot for my final project. This is my micromouse.


Monday, March 16, 2015

STM32F4 Discovery Tutorial 3 - Get Input from Button

In this tutorial, I will explain how to configure pin as an input from button. I will use user button which connected to PA0.

First, make new project called button or whatever you want. If you don’t know how to make a new project, you can learn from tutorial 2. After that don’t forget to include the library for this project.
#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_gpio.h"
Every time you want to use GPIO, you must configure RCC (Reset and Clock Control) for each GPIO.
// Enable peripheral clock to GPIOA module
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
// Enable peripheral clock to GPIOD module
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitTypeDef is a struct which used for input initialization value for GPIO.
// This is struct for configure GPIO
GPIO_InitTypeDef GPIO_InitStruct;