Home Biography Projects Final Project
Interface Programming

This week I will be making a piece of software on the computer that will read from my final project main board that I have made here. I have had previous experience with programing user interfaces in both Microsoft Access (easily make database front ends, serves as it's own database too) and Visual Studio (C# in Windows Forms), so I expect this week to be easy.

The board
The board I am using this week is driven by a 32u4, an Atmel microcontroller with built in USB capabilities. It will allow me to easlily interface with the computer without having to bother with using an FTDI cable. The built in USB also a llows for the 32u4 to be used as a keyboard, mouse, gamepad, or joystick.

The code
I will be writing my program in Visual Studio Community, the free version of Visual Studio (which is normally $1000+), in C#, a language related to C and C++. I chose this language because it is easy to write a console application with C#. I chose C# in VS over VBA in Access since I had no knowledge of how to do serial communication in VBA, and that Access can be a bit weird sometimes. I learned serial communication in C# previously, using MSDN and Stack Exchange. The code I wrote in VS waits for data to come through the serial port, reads and writes what that data says, and then goes back to waiting for serial data.

The code I wrote for the main board Checks if a button is pressed, sets a boolean to true if it is, and writes wether or not the button is pressed to the serial connection. I have incorporated a delay into the loop that does this so that the 32u4 does not flood the serial port.In the future, I could set the code up so that it only sends the not pressed string once, and this could be don on either the computer or the microchip. This willbe helpful in my final project, since I will be sending commands to the computer over serial.

I programmed the board using an ISP, starting out with the standard Arduino Micro bootloader and then installing the program. Using the code took a few attempts at getting the board to work. The virtual COM port would not show up like it did below, and it turned out that the USB port was not supplying power. I solved this issue by using an ISP as a power source. In my final project, I will supply the board with an external power source.

I attached a button to the board and attached the board to the computer. I ran the interface and pressed the button to change the printed string from the "off" text to the "on" text.

Files
BetterSerialSend.ino - Arduino code for the board
BetterInterface.ino - VS projejct files