วันจันทร์ที่ 23 มิถุนายน พ.ศ. 2557

Android Bluetooth control 8 devices with Arduino Board

-->




Android Bluetooth control 8 devices with Arduino Board
( ควบคุมอุปกรณ์ไฟฟ้า ผ่าน Bluetooth )

Arduino Bluetooth Control Device Application is to allow you to control various electrical devices up to eight devices and independently controlled.
Use Android Bluetooth mobile device to  remote control your device with Serial TTL Bluetooth Module and Arduino Board.

For Automation System ,Smart Home Automation ,light control etc.

The program features.
- Control up to  8 devices.
- Can be set Timer to ON / OFF the device and show the countdown timer.(Timer can be set to 1 minute, 15 minutes, 30 minutes, 1 hour, 2 hours, 4 hours).
- Change and Edit your Device Name. ( Version 1.6+)

Version 1.6+ your can set your device name.







Android App on Google Play


Hardware
1. Serial Port Bluetooth Module( TTL )
2. Arduino Microcontroller Board ( we use ET-BASE AVR EASY328 Arduino compatible)
3. 8 channel Output Relay Board

More info about hardware :
http://microcontrollerkits.blogspot.com/2012/02/arduino-control-8-devices-via-android.html




Arduino Development Kits on ebay
http://www.ebay.com/sch/marychanyanuch2012/m.html?



Wiring Arduino Pin Diagram

Output 1 to Pin 4 ( Arduino Board )
Output 2 to Pin 5
Output 3 to Pin 6
Output 4 to Pin 7
Output 5 to Pin 8
Output 6 to Pin 9
Output 7 to Pin 10
Output 8 to Pin 11

Bluetooth Module Tx to  Pin 0
Bluetooth Module Rx to  Pin 1




Hardware Kits









Android Control Kits


Order Hardware Kit  at  Android Bluetooth control  8 devices Kits

Visit Android Control Kits Shop


Android Bluetooth Control Device
Android Bluetooth Control Device Application is to allow you to control various electrical devices up to eight devices and independently controlled.
Use Android Bluetooth mobile device to  remote control your device with Bluetooth Receiver hardware Device.
เป็น Application ที่ทำให้คุณสามารถควบคุมอุปกรณ์ไฟฟ้าต่างๆได้ ถึง 8 อุปกรณ์โดย แยกควบคุมกันได้อย่างอิสระ
ผ่านระบบ Bluetooth ของเครื่องโทรศัพท์มือถือ Android เป็นตัว Remote Control ไปยังอุปกรณ์ภาครับ ( Bluetooth Receiver Hardware Device )

The program features.
- control up to  8 devices.
- Can be set Timer to ON / OFF the device and show the time.(the timer can be set to 1 minute, 15 minutes, 30 minutes, 1 hour, 2 hours, 4 hours).
- Use with Receiving device (Bluetooth Receiver Hardware Device - see below).
Design for the Android version 4 and a screen resolution of 480 x 800 (WVGA).
Freeware with AD (free software)


คุณสมบัติโปรแกรม
-          ควบคุมอุปกรณ์ได้ 8 อุปกรณ์
-          สามารถตั้งเวลา ปิด/เปิด แต่ละอุปกรณ์ได้ และแสดงเวลาการทำงาน และเวลาคงเหลือการตั้งเวลา ( เวลาที่สามารถตั้งได้ 1 นาที,15 นาที, 30 นาที, 1 ชั่วโมง ,2 ชั่วโมง , 4 ชั่วโมง )
-          ต้องใช้งานร่วมกับ อุปกรณ์ภาครับ ( Bluetooth Receiver Box )
ออกแบบ ค่าเริ่มต้น สำหรับ Android version 4 และ หน้าจอความละเอียด 480 x 800 ( WVGA )

A data transmission via Bluetooth. รูปแบบการส่งข้อมูลผ่าน Bluetooth
Device1 ON sent “A” , Device1 OFF sent “a”
Device2 ON sent “B” , Device2 OFF sent “b”
Device3 ON sent “C” , Device3 OFF sent “c”
Device4 ON sent “D” , Device4 OFF sent “d”
Device5 ON sent “E” , Device5 OFF sent “e”
Device6 ON sent “F” , Device6 OFF sent “f”
Device7 ON sent “G” , Device7 OFF sent “g”
Device8 ON sent “H” , Device8 OFF sent “h”



Hardware สำหรับ การสร้างอุปกรณ์ภาครับ
  จะใช้ Bluetooth Module และ Arduino Microcontroller Board และ Relay Output Board
Hardware อุปกรณ์ที่ใช้
1.       Serial Port Bluetooth Module( TTL )
2.       Microcontroller Board (ET-BASE AVR EASY328 )
3.       8 channel Output Relay Board





Bluetooth ( information form Android Developers ) ( ภาษาไทย ด้านล่าง )
Quickview
  • Android's bluetooth APIs allow your application to perform wireless data transactions with other devices
Key classes
  1. BluetoothAdapter
  2. BluetoothDevice
  3. BluetoothSocket
  4. BluetoothServerSocket
Related samples
  1. Bluetooth Chat
  2. Bluetooth HDP (Health Device Profile)
The Android platform includes support for the Bluetooth network stack, which allows a device to wirelessly exchange data with other Bluetooth devices. The application framework provides access to the Bluetooth functionality through the Android Bluetooth APIs. These APIs let applications wirelessly connect to other Bluetooth devices, enabling point-to-point and multipoint wireless features.
Using the Bluetooth APIs, an Android application can perform the following:
  • Scan for other Bluetooth devices
  • Query the local Bluetooth adapter for paired Bluetooth devices
  • Establish RFCOMM channels
  • Connect to other devices through service discovery
  • Transfer data to and from other devices
  • Manage multiple connections
·         The Basics
·       This document describes how to use the Android Bluetooth APIs to accomplish the four major tasks necessary to communicate using Bluetooth: setting up Bluetooth, finding devices that are either paired or available in the local area, connecting devices, and transferring data between devices.
·         All of the Bluetooth APIs are available in the android.bluetooth package. Here's a summary of the classes and interfaces you will need to create Bluetooth connections:
·         BluetoothAdapter
·       Represents the local Bluetooth adapter (Bluetooth radio). The BluetoothAdapter is the entry-point for all Bluetooth interaction. Using this, you can discover other Bluetooth devices, query a list of bonded (paired) devices, instantiate a BluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for communications from other devices.
·         BluetoothDevice
·       Represents a remote Bluetooth device. Use this to request a connection with a remote device through a BluetoothSocket or query information about the device such as its name, address, class, and bonding state.
·         BluetoothSocket
·         Represents the interface for a Bluetooth socket (similar to a TCP Socket). This is the connection point that allows an application to exchange data with another Bluetooth device via InputStream and OutputStream.
·         BluetoothServerSocket
·         Represents an open server socket that listens for incoming requests (similar to a TCP ServerSocket). In order to connect two Android devices, one device must open a server socket with this class. When a remote Bluetooth device makes a connection request to the this device, the BluetoothServerSocket will return a connected BluetoothSocket when the connection is accepted.
·         BluetoothClass
·         Describes the general characteristics and capabilities of a Bluetooth device. This is a read-only set of properties that define the device's major and minor device classes and its services. However, this does not reliably describe all Bluetooth profiles and services supported by the device, but is useful as a hint to the device type.
·         BluetoothProfile
·         An interface that represents a Bluetooth profile. A Bluetooth profile is a wireless interface specification for Bluetooth-based communication between devices. An example is the Hands-Free profile. For more discussion of profiles, see Working with Profiles
·         BluetoothHeadset
·         Provides support for Bluetooth headsets to be used with mobile phones. This includes both Bluetooth Headset and Hands-Free (v1.5) profiles.
·         BluetoothA2dp
·         Defines how high quality audio can be streamed from one device to another over a Bluetooth connection. "A2DP" stands for Advanced Audio Distribution Profile.
·         BluetoothHealth
·         Represents a Health Device Profile proxy that controls the Bluetooth service.
·         BluetoothHealthCallback
·         An abstract class that you use to implement BluetoothHealth callbacks. You must extend this class and implement the callback methods to receive updates about changes in the application’s registration state and Bluetooth channel state.
·         BluetoothHealthAppConfiguration
·         Represents an application configuration that the Bluetooth Health third-party application registers to communicate with a remote Bluetooth health device.
·         An interface that notifies BluetoothProfile IPC clients when they have been connected to or disconnected from the service (that is, the internal service that runs a particular profile). 

 Class Bluetooth นี้จะทำงานสนับสนุนเครือข่ายบลูทูธสแต็คที่ช่วยให้อุุปกรณ์ไร้สาย แลกเปลี่ยนข้อมูลกับอุุปกรณ์บลูทูธอื่น ๆ ให้การเข้าถึงฟังก์ชันการทำงานบลูทูธ ผ่าน Android API   APIs จะขอเชื่อมต่อกับอุปกรณ์บลูทูธอื่น ๆ ที่เปิดใช้งานแบบ point-to-point และมีคุณลักษณะหลายแบบรูปแบบ

การใช้บลูทูธ APIs, โปรแกรม Android สามารถดำเนินการต่อไปนี้:

     สแกนหาอุปกรณ์บลูทูธ อื่น ๆ
     อะแดปเตอร์บลูทูธ แบบสอบถามในท้องถิ่นสำหรับการจับคู่อุปกรณ์บลูทูธ
     สร้างช่องทาง RFCOMM
     เชื่อมต่อกับอุปกรณ์อื่น ๆ ผ่านทางบริการการค้นหา
     ถ่ายโอนข้อมูลไปและกลับจากอุปกรณ์อื่น ๆ
     จัดการการเชื่อมต่อหลาย


ข้อมูลพื้นฐาน

เอกสารนี้จะอธิบายวิธีการใช้บลูทูธ Android API เพื่องานหลักที่จำเป็นในการติดต่อสื่อสารโดยใช้บลูทูธ : ตั้งค่าบลูทูธ , การหาอุปกรณ์ที่จะจับคู่หรือบริการในพื้นที่ท้องถิ่นที่เชื่อมต่อ อุุุุปกรณ์และการถ่ายโอนข้อมูลระหว่างอุปกรณ์ทั้งหมดของบลูทูธ APIs ที่มีอยู่ในแพคเกจ android.bluetooth นี่เป็นบทสรุป และอินเตอร์เฟซที่คุณจะต้องสร้างการเชื่อมต่อบลูทูธ


BluetoothAdapter
หมายถึงอะแดปเตอร์บลูทูธ  (บลูทูธคลื่นวิทยุ) BluetoothAdapter เป็นการควบคุมบลูทูธ ทั้งหมด ใช้นี้คุณสามารถค้นพบอุปกรณ์บลูทูธ อื่น ๆ สอบถามรายชื่อของการจับคู่บลูทูธ อุปกรณ์, ยกตัวอย่าง BluetoothDevice ใช้ที่อยู่ MAC รู้จักและสร้าง BluetoothServerSocket ฟังสำหรับการสื่อสารจากอุปกรณ์อื่น ๆ


 BluetoothDevice
หมายถึงอุปกรณ์บลูทูธ จากระยะไกล เพื่อร้องขอการเชื่อมต่อกับอุปกรณ์จากระยะไกลผ่าน BluetoothSocket หรือข้อมูลเกี่ยวกับอุปกรณ์ต่างๆ เช่น ชื่อ ที่อยู่ ระดับ Class


BluetoothSocket
หมายถึงอินเตอร์เฟซสำหรับซ็อกเก็ตบลูทูธ (คล้ายกับ TCP Socket) ตรงนี้คือจุดเชื่อมต่อที่ช่วยให้แอพลิเคชันเพื่อแลกเปลี่ยนข้อมูลกับอุปกรณ์ Bluetooth อื่นๆ ผ่านทาง InputStream และ OutputStream


BluetoothServerSocket
·หมายถึงซ็อกเก็ตเซิร์ฟเวอร์เปิดที่ฟังการร้องขอเข้ามา (คล้ายกับ TCP ServerSocket) เพื่อที่จะเชื่อมต่ออุปกรณ์สอง Android, เครื่องหนึ่งจะต้องเปิดเซิร์ฟเวอร์ซ็อกเก็ตที่มีชั้นนี้ เมื่ออุปกรณ์บลูทู ธ จากระยะไกลทำให้การร้องขอการเชื่อมต่อกับอุปกรณ์นี้ BluetoothServerSocket จะกลับ BluetoothSocket ที่เชื่อมต่อเมื่อเชื่อมต่อได้รับการยอมรับ
 

BluetoothClass
อธิบายลักษณะทั่วไปและความสามารถของอุปกรณ์บลูทูธนี้ เป็นคุณสมบัติที่กำหนดของอุปกรณ์หลักและรองในระดับชั้นอุปกรณ์และบริการของบริษัท แต่นี้ไม่ได้อธิบายโปรไฟล์บลูทูธ และบริการทั้งหมดได้รับการสนับสนุนโดยอุปกรณ์ แต่จะมีประโยชน์เป็นการบอกข้อมูลเบื่องต้นของประเภทของอุปกรณ์
 

BluetoothProfile
เป็นอินเตอร์เฟซที่แสดงถึงรายละเอียดบลูทูธ เป็นข้อกำหนดอินเตอร์เฟซแบบไร้สายบลูทูธ สำหรับการสื่อสารที่ใช้ระหว่างอุปกรณ์ ตัวอย่าง คือรายละเอียดของข้อมูลแฮนด์ฟรี


BluetoothHeadset
เป็นให้การสนับสนุนสำหรับชุดหูฟังบลูทูธ ที่จะใช้กับโทรศัพท์มือถือ ซึ่งรวมถึงชุดหูฟังบลูทูธ และแฮนด์ฟรีโปรไฟล์ (v1.5)


BluetoothA2dp
เป็นการกำหนด ข้อมูลเสียงที่มีคุณภาพสูงสามารถสตรีมจากเครื่องหนึ่งไปยังอีกกว่าการเชื่อมต่อบลูทูธ "A2DP" หมายถึงรายละเอียดการส่งข้อมูล ระบบเสียงขั้นสูง


BluetoothHealth
หมายถึง พร็อกซี่ ที่ควบคุมการให้บริการบลูทูธ
 ด้านอุปกรณ์เพื่อสุขภาพ หรือเครื่องมือแพทย์

BluetoothHealthCallback
เป็นการดำเนินการเรียกข้อมูลกลับมาจาก BluetoothHealth ใช้วิธีการส่งข้อมูลกลับเพื่อรับการปรับปรุงเกี่ยวกับการเปลี่ยนแปลงในสถานะการลงทะเบียนของโปรแกรมประยุกต์และ ปรับปรุงช่องทางการสื่อสารของบลูทูธ


BluetoothHealthAppConfiguration
หมายถึงการกำหนดค่าโปรแกรมประยุกต์บลูทูธด้านสุขภาพของบุคคลอื่น ที่ลงทะเบียนในการสื่อสารกับอุปกรณ์บลูทูธ จากระยะไกล


BluetoothProfile.ServiceListener
เป็นอินเตอร์เฟซที่แจ้งให้ BluetoothProfile IPC เมื่อได้รับการเชื่อมต่อไปยังหรือตัดการเชื่อมต่อจากการให้บริการ (นั่นคือการให้บริการภายในที่ทำงานรายละเอียดตามที่กำหนดไว้)










 รับเขียนโปรแกรม Android Application และสอนการเขียนโปรแกรม สอน online ได้

อดุลย์ 081-6452400  e-mail fongwe_a@hotmail.com
 สอนเขียนโปรแกรม Android Application สอนแบบ online ได้ทั่วประเทศ กำหนดเวลาเรียนได้
การเรียน Android Application แบบ online สามารถกำหนดเวลาเรียน เองได้ ตามแต่ตกลงกัน

Course
1.JAVA Programming สำหรับผู้ที่ยังไม่มีพื้นฐานทางด้าน การเขียนโปรแกรม JAVA
เรียน 3-5 ครั้ง ครั้งละ 2 ชั่วโมง 

2.Beginning Android Development เริ่มต้นการพัฒนาด้วย Android ( ต้องมีพื้นฐาน JAVA แล้ว )
เรียน 5-7 ครั้ง ครั้งละ 2 ชั่วโมง 

3.Android Application สอนตามความต้องการในการเขียนโปรแกรม ใช้งานจริง เช่น โปรแกมเกม หรือ โปรแกรมใช้งานด้านต่างๆ
ระยะเวลา และ ค่าเรียน ตามแต่ความยากง่ายของโปรแกรม ซึ่งอาจจะรวมสอน JAVA Programming ด้วยสำหรับผู้เริ่มต้นเลย

more info about Android Development
http://androiddevelopersthai.blogspot.com/

Android example code 
http://androidcodeexample.blogspot.com/




วันพฤหัสบดีที่ 5 มิถุนายน พ.ศ. 2557

NFC Guard Tour System


NFC Guard Tour System

Turn you android device to Guard Tour System.
This App use with NFC Tags with Android device is support NFC.

The Application Features
  • Read/Write NFC tag .
  • When read NFC data and record in to database.
  • Write data ( Text ) in to NFC Tag.
  • Save Export Database to text file.
Video in Thai Language



User Manual 


First Login to Admin page

user : admin        (  don't change this name. )
password :1234   (  you can change later )



Write Data to NFC tag for check point.




Add New User for security guard. 
Add already. Exit and login again as new user.



Ready to Use.
Bring your Android device tab to NFC tag.



Save Database to text File.
Must login to admin again.

  •  Text file in SD Card ( in folder /sdcard/file/Logxxxx-xxxx.text )
  • Format Name File  =  LogYYMMDD-hhmm.txt

When you've saved already.
Clear Database Button will enable.
So you can clear all database.


Export to Text File.


Android App on Google Play.






More About NFC / RFID App




วันอาทิตย์ที่ 2 มีนาคม พ.ศ. 2557

Unity3D Game Build to Android



Unity3D Game Build to Android

Original Source Code from Unity Technologies.
https://www.assetstore.unity3d.com/#/content/13866


Getting Started with Android Development

Building games for a device running Android OS. However, the hardware is not completely standardized across all devices. There are some feature differences in the Android version.
Setting up your Android Developer environment
You will need to have your Android developer environment set up before you can test your Unity games on the device. This involves downloading and installing the Android SDK with the different Android platforms and adding your physical device to your system (this is done a bit differently depending on whether you are developing on Windows or Mac). This setup process is explained on the Android developer website, and there may be additional information provided by the manufacturer of your device. Since this is a complex process, we've provided a basic outline of the tasks that must be completed before you can run code on your Android device or in the Android emulator. However, the best thing to do is follow the instructions step-by-step from the Android developer portal.
Access Android Functionality
Unity Android provides scripting APIs to access various input data and settings. You can find out more about the available classes on the Android scripting page.
Exposing Native C, C++ or Java Code to Scripts
Unity Android allows you to call custom functions written in C/C++ directly from C# scripts (Java functions can be called indirectly). To find out how to make functions from native code accessible from Unity, visit the Android plugins page.
Occlusion Culling
Unity includes support for occlusion culling which is a particularly valuable optimization on mobile platforms. More information can be found on the occlusion culling page.
Splash Screen Customization
The splash screen displayed while the game launches can be customized - see this page for further details.
Troubleshooting and Bug Reports
There are many reasons why your application may crash or fail to work as you expected. Our Android troubleshooting guide will help you get to the bottom of bugs as quickly as possible. If, after consulting the guide, you suspect the problem is internal to Unity then you should file a bug report - see this page for details on how to do this.

How Unity Android Differs from Desktop Unity

Strongly Typed JavaScript

For performance reasons, dynamic typing in JavaScript is always turned off in Unity Android, as if #pragma strict were applied automatically to all scripts. This is important to know if you start with a project originally developed for the desktop platforms since you may find you get unexpected compile errors when switching to Android; dynamic typing is the first thing to investigate. These errors are usually easy to fix if you make sure all variables are explicitly typed or use type inference on initialization.

ETC as Recommended Texture Compression

Although Unity Android does support DXT/PVRTC/ATC textures, Unity will decompress the textures into RGB(A) format at runtime if those compression methods are not supported by the particular device in use. This could have an impact on the GPU rendering speed and it is recommended to use the ETC format instead. ETC is the de facto standard compression format on Android, and should be supported on all post 2.0 devices. However, ETC does not support an alpha channel and RGBA 16-bit will sometimes be the best trade-off between size, quality and rendering speed where alpha is required.
It is also possible to create separate android distribution archives (.apk) for each of the DXT/PVRTC/ATC formats, and let the Android Market's filtering system select the correct archives for different devices (see Publishing Builds for Android).

Movie Playback

Movie textures are not supported on Android, but a full-screen streaming playback is provided via scripting functions. To learn about supported file formats and scripting API, consult the movie page or the Android supported media formats page.


Android SDK Setup

There are some steps you must follow before you can build and run any code on your Android device. This is true regardless of whether you use Unity or write Android applications from scratch.

1. Download the Android SDK

Go to the Android Developer SDK webpage. Download and unpack the latest Android SDK.

2. Installing the Android SDK

Follow the instructions under Installing the SDK (although you can freely skip the optional parts relating to Eclipse). In step 4 of Installing the SDK be sure to add at least oneAndroid platform with API level equal to or higher than 9 (Platform 2.3 or greater), the Platform Tools, and the USB drivers if you're using Windows.

3. Get the device recognized by your system

This can be tricky, especially under Windows based systems where drivers tend to be a problem. Also, your device may come with additional information or specific drivers from the manufacturer.
For Windows: If the Android device is automatically recognized by the system you still might need to update the drivers with the ones that came with the Android SDK. This is done through the Windows Device Manager.
If the device is not recognized automatically use the drivers from the Android SDK, or any specific drivers provided by the manufacturer.
Additional info can be found here: USB Drivers for Windows
For Mac: If you're developing on Mac OSX then no additional drivers are usually required.
Note: Don't forget to turn on "USB Debugging" on your device. Go to Settings -> Developer options, then enable USB debugging. As of Android Jelly Bean 4.2 the Developer options are hidden by default. To enable them tap on Settings -> About Phone -> Build Version multiple times. Then you will be able to access the Settings -> Developer options.
If you are unsure whether your device is properly installed on your system, please read the trouble-shooting page for details.

4. Add the Android SDK path to Unity

The first time you build a project for Android (or if Unity later fails to locate the SDK) you will be asked to locate the folder where you installed the Android SDK (you should select the root folder of the SDK installation). The location of the Android SDK can also be changed in the editor by selecting Unity > Preferences from the menu and then clicking on External Tools in the preferences window.








How to Build App to Android  ( Unity 4.3.1 )

First  Android SDK Setup

Use Menu  :  Edit  -  Preferences  Then Select Android SDK Location



Set Google Play Publishing Settings 

Use Menu  :  Edit -  Project Settings - Player

  

Then Show PlayerSettings



Resolution and Presentation
You can set Android Device Screen Orientation.


Icon
show your icon on different screen android devices.


Splash Image
not use.

Other Settings
Set your Android Package , Version Code , Version Name and minimum sdk.



Publishing Settings
You can set keystore. Create New KeyStore or Use Existing KeyStore.



Android App on Google Play.




Space Shooter Game is simple demo 2D game from Unity Asset Store.
Easy Game for kid. Shoot Asteroid and enemy.
Use only one Finger to Play.

Original Source Code from Unity Technologies.
https://www.assetstore.unity3d.com/#/content/13866

How to Play
Use only one Finger to Play.
Touch to shoot lasers.
Touch to Move Left ,Right ,Up Down

เกมยิงยานอวกาศ Space Shooter Game
เกมที่ง่าย ๆ สำหรับเด็ก ยิงดาวเคราะห์น้อยและยานบินศัตรู

เกมนี้ เอา Free Source code มาจาก Unity แล้วมาทำลง Android
https://www.assetstore.unity3d.com/#/content/13866 

วิธีการเล่น
สัมผัสที่จะยิงเลเซอร์
สัมผัสเพื่อย้ายไปทางซ้าย, ขวา, ขึ้น, ลง

More Android App on Google Play.