3-LED Backlight: Xamarin and Arduino With HC05

Today im gonna show you how to make a full Androidapp-controllable LED Backlight for your TV for under 10$.

In this Instructable i will show you:

To use my Xamarin Bluetooth-APP(Open Source C#-Code)

Programming your Arduino

And let them communicate to each other

I am using an Arduino Uno r3(Sainsmart UNO) for the HC-05 and Visual Studio Ultimate 2013(Xamarin Plug-In) for programming our Bluetoothsoftware. I really looked a long time on the internet to find such a tutorial, but there just were a few good tutorials, which only described the Xamarin- or the Arduino-sided stuff well. Especially the the compatibilty of my Smartphone(Android 4.1.2) made huge problems, but i found a solution which worked for me. And it runs more stable on Android 5.0> :). Ok Here we go:

You will need:

Arduino(Mega, uno, etc.)

HC-05(HC-06 is also possible)

Xamarin Plugin or IDE. It's free for 30 days of trial (https://www.xamarin.com/)

Actuallly this Instructable is not directed to C#-Programming, but the code should be easy to understand.

If not post a comment, or write a message :)

Step 1: The Xamarin - Code

Okay first of all we have to write our Code:

Make your own Design or use mine(recommended) to have a GUI which the user can use easily.

"Disconnect" causes an event which sends the value 187 to the Arduino which restarts the HC-05(required).

The Buttons LED1, LED2, LED3 causes the event to send a 1,2 or 3 to the Arduino.

The Brightness seekBar sends a value between 10 and 168.

Download below !

_____

Create a new Xamarin-Project and call it e.g. "BluetoothApp".

When you have done this, please change the namespace (Options>Android options) to Backlight, or change the namespace in the MainActivity.cs, you already integrated, to yours. After this you have to pair your device over Bluetoothsettings.

We want to create this App as easy as possible, so we only use the static name of our HC-05/-06 in my case the standard name of this module "HC-05" to connect and communicate.

The only thing i found out to get this work is to create a "BluetoothDevice" by using the Name "HC-05" of your Bluetoothmodule. When I try to create a BluetoothSocket with a BluetoothDevice which is not created with the name, it crashes. I dont know why but it's a adequately solution.

In my code you can change the name to your devices name in the class BluetoothConnection. This step is required to get the App running!

Attachments

Step 2: Arduino Code

In this .ino file you find the program i am running on my Sainsmart Uno. I used numbers to code the information i want to transmit, e.g. '187' for killing, '1' for LED one etc. There are also values between 15 and 168 for the brightness given by the APP(Slidebar). The standard brightness is 80.

I used following Pin-assignments:

13 - Pinout TTL 5V for HC05/06-Supplyvoltage(and also for restarting)

3,5 and 6 - PWM output for LED's

Tx - to HC05/06 Rx

Rx - to HC05/06 Tx ( a bit confusing, but very important! )

GND - TO HC05/06 GND

In some documentations I found a voltage divider between Tx and Rx(and of course GND) to set the Voltage to 3.3V, but my HC05/06 also works great with 5V potential. So just connect and go on! :)

________

I also tried this with an AtTiny45, but this is a bit more complicated, becauce this IC only has one PWM-port and you need 3 for 3 LED's. That's why you have to programm a timer.

Make it Glow Contest 2018

Optics Contest

Plastics Contest

15 Discussions

I am really enjoying reading your well-written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.

Thank you so much. I send data to my special bluetooth device which is not Arduino+HC05+BTModul. After I send data, I want to read that coming data from my special bluetooth device by changing Baud Rate. How Can I do this?