├── LED-master
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── assets
│ │ │ │ └── sanslight.otf
│ │ │ ├── ic_launcher-web.png
│ │ │ ├── res
│ │ │ │ ├── drawable
│ │ │ │ │ ├── led.png
│ │ │ │ │ ├── cover.png
│ │ │ │ │ ├── web_red.png
│ │ │ │ │ ├── developer.png
│ │ │ │ │ ├── facebook_red.png
│ │ │ │ │ ├── twitter_red.png
│ │ │ │ │ ├── instagram_red.png
│ │ │ │ │ └── rounded_button.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values
│ │ │ │ │ ├── styles.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ └── strings.xml
│ │ │ │ ├── menu
│ │ │ │ │ ├── menu_device_list.xml
│ │ │ │ │ └── menu_led_control.xml
│ │ │ │ ├── values-w820dp
│ │ │ │ │ └── dimens.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── splash.xml
│ │ │ │ │ ├── activity_device_list.xml
│ │ │ │ │ ├── activity_led_control.xml
│ │ │ │ │ └── activity_about.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── led_on_off
│ │ │ │ │ └── led
│ │ │ │ │ ├── SplashScreen.java
│ │ │ │ │ ├── AboutActivity.java
│ │ │ │ │ ├── DeviceList.java
│ │ │ │ │ └── ledControl.java
│ │ │ └── AndroidManifest.xml
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── led_on_off
│ │ │ └── led
│ │ │ └── ApplicationTest.java
│ ├── app-release.apk
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── app.iml
├── settings.gradle
├── .gitignore
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .idea
│ ├── caches
│ │ └── build_file_checksums.ser
│ ├── modules.xml
│ ├── runConfigurations.xml
│ ├── gradle.xml
│ ├── misc.xml
│ └── codeStyles
│ │ └── Project.xml
├── build.gradle
├── LED.iml
├── gradle.properties
├── gradlew.bat
└── gradlew
├── LED Controller APK
└── LED Controller.apk
├── README.md
├── BT_changed_transmission_pins
├── BT_changed_transmission_pins.ino
└── README.md
└── Arduino Code
└── Arduino_Bluetooth_Basic.ino
/LED-master/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/assets/sanslight.otf:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/LED-master/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/LED-master/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/LED-master/app/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/app-release.apk
--------------------------------------------------------------------------------
/LED Controller APK/LED Controller.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED Controller APK/LED Controller.apk
--------------------------------------------------------------------------------
/LED-master/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/led.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/led.png
--------------------------------------------------------------------------------
/LED-master/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/LED-master/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/cover.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/web_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/web_red.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/developer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/developer.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/facebook_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/facebook_red.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/twitter_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/twitter_red.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/instagram_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/drawable/instagram_red.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mayoogh/Arduino-Bluetooth-Basic/HEAD/LED-master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/LED-master/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LED
3 |
4 | Hello world!
5 | Settings
6 | ledControl
7 | AboutActivity
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Arduino-Bluetooth-Basic
2 | Control a LED using your smartphone via bluetooth
3 | Download the app from here : http://goo.gl/PSXVoF
4 |
5 | Project Documentation can be found [here](http://mgprojecthub.com/arduino-bluetooth-basic-tutorial/)
6 |
7 |
8 |
NOTE : This Application does not support Bluetooth Low Energy (BLE). Only works with SPP
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LED-master/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/drawable/rounded_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/menu/menu_device_list.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/menu/menu_led_control.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/LED-master/app/src/androidTest/java/com/led_on_off/led/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.led_on_off.led;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/LED-master/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.5.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BT_changed_transmission_pins/BT_changed_transmission_pins.ino:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 | char state = '0';
5 |
6 | SoftwareSerial BT(3,2); // BT(Tx,Rx)
7 |
8 | void setup() {
9 | BT.begin(9600); // Initialize serial communication at 9600 bits per second
10 |
11 | Serial.begin(9600);
12 | }
13 | void loop() {
14 |
15 | Serial.begin(9600);
16 | if(BT.available()){
17 | // Reads from bluetooth and stores its value
18 | state = BT.read();
19 | // Write your Code here
20 | // Better to use switch function
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/LED-master/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LED-master/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "com.led.led_on_off"
9 | minSdkVersion 14
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:21.0.3'
25 | }
26 |
--------------------------------------------------------------------------------
/LED-master/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LED-master/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Deyson\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/BT_changed_transmission_pins/README.md:
--------------------------------------------------------------------------------
1 | ## Usage of other GPIO for serial communication
2 |
3 | `BT_changed_transmission_lines.ino` code consist of a library `SoftwareSerial`.
4 |
5 | This Library allows you to select your own Tx and Rx pins.
6 |
7 | For eg: In code, pins (3,2) is taken which means pin 3 of MCU is connected with Rx of BT and pin 2 to Tx of BT.
8 |
9 | The default Tx,Rx pins can be used for other purposes.
10 |
11 | Multiple serial port can be defined using this library
12 |
13 | Syntax : `SoftwareSerial mySerial(receivePin, transmitPin)`
14 |
15 |
16 |
17 | Read more at here [[1]](https://www.arduino.cc/en/Reference.SoftwareSerial) [[2]](https://www.renesas.com/us/en/products/gadget-renesas/reference/gr-adzuki/library-softwareserial.html)
18 |
19 |
--------------------------------------------------------------------------------
/LED-master/LED.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/LED-master/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/layout/splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
28 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/java/com/led_on_off/led/SplashScreen.java:
--------------------------------------------------------------------------------
1 | package com.led_on_off.led;
2 | import android.app.Activity;
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 |
6 | /**
7 | * Created by PEACE on 3/30/2016.
8 | */
9 | public class SplashScreen extends Activity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | // TODO Auto-generated method stub
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.splash);
16 |
17 | Thread timerThread = new Thread(){
18 | public void run(){
19 | try{
20 | sleep(700);
21 | }catch(InterruptedException e){
22 | e.printStackTrace();
23 | }finally{
24 | Intent intent = new Intent(SplashScreen.this,DeviceList.class);
25 | startActivity(intent);
26 | }
27 | }
28 | };
29 | timerThread.start();
30 | }
31 |
32 | @Override
33 | protected void onPause() {
34 | // TODO Auto-generated method stub
35 | super.onPause();
36 | finish();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/Arduino Code/Arduino_Bluetooth_Basic.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * Bluetooh Basic: LED ON OFF - Avishkar
3 | * Coder - Mayoogh Girish
4 | * Website - http://bit.do/Avishkar
5 | * Download the App :
6 | * This program lets you to control a LED on pin 13 of arduino using a bluetooth module
7 | */
8 | char Incoming_value = 0; //Variable for storing Incoming_value
9 | void setup()
10 | {
11 | Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
12 | pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
13 | }
14 | void loop()
15 | {
16 | if(Serial.available() > 0)
17 | {
18 | Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value
19 | Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor
20 | Serial.print("\n"); //New line
21 | if(Incoming_value == '1') //Checks whether value of Incoming_value is equal to 1
22 | digitalWrite(13, HIGH); //If value is 1 then LED turns ON
23 | else if(Incoming_value == '0') //Checks whether value of Incoming_value is equal to 0
24 | digitalWrite(13, LOW); //If value is 0 then LED turns OFF
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/java/com/led_on_off/led/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package com.led_on_off.led;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.v7.app.ActionBarActivity;
7 | import android.view.View;
8 |
9 | public class AboutActivity extends ActionBarActivity
10 | {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState)
14 | {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_about);
17 | }
18 |
19 | public void fb(View view)
20 | {
21 | Intent fbIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/mayoogh"));
22 | startActivity(fbIntent);
23 | }
24 |
25 | public void tweet(View view)
26 | {
27 | Intent tweetIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/mayoogh1997/"));
28 | startActivity(tweetIntent);
29 | }
30 |
31 | public void insta(View view)
32 | {
33 | Intent instaIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.instagram.com/mayoogh/"));
34 | startActivity(instaIntent);
35 | }
36 |
37 |
38 | public void web(View view)
39 | {
40 | Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://mayooghgirish.ml"));
41 | startActivity(webIntent);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/LED-master/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LED-master/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/layout/activity_device_list.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
22 |
23 |
36 |
37 |
45 |
46 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/LED-master/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/layout/activity_led_control.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
21 |
22 |
23 |
37 |
38 |
51 |
52 |
64 |
65 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
32 |
33 |
45 |
46 |
47 |
56 |
57 |
66 |
67 |
76 |
77 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/java/com/led_on_off/led/DeviceList.java:
--------------------------------------------------------------------------------
1 | package com.led_on_off.led;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.os.Bundle;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 | import android.widget.AdapterView;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.Button;
12 | import android.widget.ListView;
13 | import android.bluetooth.BluetoothAdapter;
14 | import android.bluetooth.BluetoothDevice;
15 | import android.widget.TextView;
16 | import android.widget.Toast;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Set;
20 |
21 |
22 | public class DeviceList extends ActionBarActivity
23 | {
24 | //widgets
25 | Button btnPaired;
26 | ListView devicelist;
27 | //Bluetooth
28 | private BluetoothAdapter myBluetooth = null;
29 | private Set pairedDevices;
30 | public static String EXTRA_ADDRESS = "device_address";
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState)
34 | {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_device_list);
37 |
38 | //Calling widgets
39 | btnPaired = (Button)findViewById(R.id.button);
40 | devicelist = (ListView)findViewById(R.id.listView);
41 |
42 | //if the device has bluetooth
43 | myBluetooth = BluetoothAdapter.getDefaultAdapter();
44 |
45 | if(myBluetooth == null)
46 | {
47 | //Show a mensag. that the device has no bluetooth adapter
48 | Toast.makeText(getApplicationContext(), "Bluetooth Device Not Available", Toast.LENGTH_LONG).show();
49 |
50 | //finish apk
51 | finish();
52 | }
53 | else if(!myBluetooth.isEnabled())
54 | {
55 | //Ask to the user turn the bluetooth on
56 | Intent turnBTon = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
57 | startActivityForResult(turnBTon,1);
58 | }
59 |
60 | btnPaired.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v)
63 | {
64 | pairedDevicesList();
65 | }
66 | });
67 |
68 | }
69 |
70 | private void pairedDevicesList()
71 | {
72 | pairedDevices = myBluetooth.getBondedDevices();
73 | ArrayList list = new ArrayList();
74 |
75 | if (pairedDevices.size()>0)
76 | {
77 | for(BluetoothDevice bt : pairedDevices)
78 | {
79 | list.add(bt.getName() + "\n" + bt.getAddress()); //Get the device's name and the address
80 | }
81 | }
82 | else
83 | {
84 | Toast.makeText(getApplicationContext(), "No Paired Bluetooth Devices Found.", Toast.LENGTH_LONG).show();
85 | }
86 |
87 | final ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list);
88 | devicelist.setAdapter(adapter);
89 | devicelist.setOnItemClickListener(myListClickListener); //Method called when the device from the list is clicked
90 |
91 | }
92 |
93 | private AdapterView.OnItemClickListener myListClickListener = new AdapterView.OnItemClickListener()
94 | {
95 | public void onItemClick (AdapterView> av, View v, int arg2, long arg3)
96 | {
97 | // Get the device MAC address, the last 17 chars in the View
98 | String info = ((TextView) v).getText().toString();
99 | String address = info.substring(info.length() - 17);
100 |
101 | // Make an intent to start next activity.
102 | Intent i = new Intent(DeviceList.this, ledControl.class);
103 |
104 | //Change the activity.
105 | i.putExtra(EXTRA_ADDRESS, address); //this will be received at ledControl (class) Activity
106 | startActivity(i);
107 | }
108 | };
109 |
110 |
111 | @Override
112 | public boolean onCreateOptionsMenu(Menu menu)
113 | {
114 | // Inflate the menu; this adds items to the action bar if it is present.
115 | getMenuInflater().inflate(R.menu.menu_device_list, menu);
116 | return true;
117 | }
118 |
119 | @Override
120 | public boolean onOptionsItemSelected(MenuItem item) {
121 | // Handle action bar item clicks here. The action bar will
122 | // automatically handle clicks on the Home/Up button, so long
123 | // as you specify a parent activity in AndroidManifest.xml.
124 | int id = item.getItemId();
125 |
126 | //noinspection SimplifiableIfStatement
127 | if (id == R.id.action_settings) {
128 | return true;
129 | }
130 |
131 | return super.onOptionsItemSelected(item);
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/LED-master/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/LED-master/app/src/main/java/com/led_on_off/led/ledControl.java:
--------------------------------------------------------------------------------
1 | package com.led_on_off.led;
2 |
3 | import android.support.v7.app.ActionBarActivity;
4 | import android.os.Bundle;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 |
8 | import android.bluetooth.BluetoothSocket;
9 | import android.content.Intent;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.ImageButton;
13 | import android.widget.Toast;
14 | import android.app.ProgressDialog;
15 | import android.bluetooth.BluetoothAdapter;
16 | import android.bluetooth.BluetoothDevice;
17 | import android.os.AsyncTask;
18 |
19 | import java.io.IOException;
20 | import java.util.UUID;
21 |
22 |
23 | public class ledControl extends ActionBarActivity {
24 |
25 | // Button btnOn, btnOff, btnDis;
26 | Button On, Off, Discnt, Abt;
27 | String address = null;
28 | private ProgressDialog progress;
29 | BluetoothAdapter myBluetooth = null;
30 | BluetoothSocket btSocket = null;
31 | private boolean isBtConnected = false;
32 | //SPP UUID. Look for it
33 | static final UUID myUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState)
37 | {
38 | super.onCreate(savedInstanceState);
39 |
40 | Intent newint = getIntent();
41 | address = newint.getStringExtra(DeviceList.EXTRA_ADDRESS); //receive the address of the bluetooth device
42 |
43 | //view of the ledControl
44 | setContentView(R.layout.activity_led_control);
45 |
46 | //call the widgets
47 | On = (Button)findViewById(R.id.on_btn);
48 | Off = (Button)findViewById(R.id.off_btn);
49 | Discnt = (Button)findViewById(R.id.dis_btn);
50 | Abt = (Button)findViewById(R.id.abt_btn);
51 |
52 | new ConnectBT().execute(); //Call the class to connect
53 |
54 | //commands to be sent to bluetooth
55 | On.setOnClickListener(new View.OnClickListener()
56 | {
57 | @Override
58 | public void onClick(View v)
59 | {
60 | turnOnLed(); //method to turn on
61 | }
62 | });
63 |
64 | Off.setOnClickListener(new View.OnClickListener() {
65 | @Override
66 | public void onClick(View v)
67 | {
68 | turnOffLed(); //method to turn off
69 | }
70 | });
71 |
72 | Discnt.setOnClickListener(new View.OnClickListener()
73 | {
74 | @Override
75 | public void onClick(View v)
76 | {
77 | Disconnect(); //close connection
78 | }
79 | });
80 |
81 |
82 | }
83 |
84 | private void Disconnect()
85 | {
86 | if (btSocket!=null) //If the btSocket is busy
87 | {
88 | try
89 | {
90 | btSocket.close(); //close connection
91 | }
92 | catch (IOException e)
93 | { msg("Error");}
94 | }
95 | finish(); //return to the first layout
96 |
97 | }
98 |
99 | private void turnOffLed()
100 | {
101 | if (btSocket!=null)
102 | {
103 | try
104 | {
105 | btSocket.getOutputStream().write("0".toString().getBytes());
106 | }
107 | catch (IOException e)
108 | {
109 | msg("Error");
110 | }
111 | }
112 | }
113 |
114 | private void turnOnLed()
115 | {
116 | if (btSocket!=null)
117 | {
118 | try
119 | {
120 | btSocket.getOutputStream().write("1".toString().getBytes());
121 | }
122 | catch (IOException e)
123 | {
124 | msg("Error");
125 | }
126 | }
127 | }
128 |
129 | // fast way to call Toast
130 | private void msg(String s)
131 | {
132 | Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show();
133 | }
134 |
135 | public void about(View v)
136 | {
137 | if(v.getId() == R.id.abt)
138 | {
139 | Intent i = new Intent(this, AboutActivity.class);
140 | startActivity(i);
141 | }
142 | }
143 |
144 | @Override
145 | public boolean onCreateOptionsMenu(Menu menu) {
146 | // Inflate the menu; this adds items to the action bar if it is present.
147 | getMenuInflater().inflate(R.menu.menu_led_control, menu);
148 | return true;
149 | }
150 |
151 | @Override
152 | public boolean onOptionsItemSelected(MenuItem item) {
153 | // Handle action bar item clicks here. The action bar will
154 | // automatically handle clicks on the Home/Up button, so long
155 | // as you specify a parent activity in AndroidManifest.xml.
156 | int id = item.getItemId();
157 |
158 | //noinspection SimplifiableIfStatement
159 | if (id == R.id.action_settings) {
160 | return true;
161 | }
162 |
163 | return super.onOptionsItemSelected(item);
164 | }
165 |
166 |
167 |
168 | private class ConnectBT extends AsyncTask // UI thread
169 | {
170 | private boolean ConnectSuccess = true; //if it's here, it's almost connected
171 |
172 | @Override
173 | protected void onPreExecute()
174 | {
175 | progress = ProgressDialog.show(ledControl.this, "Connecting...", "Please wait!!!"); //show a progress dialog
176 | }
177 |
178 | @Override
179 | protected Void doInBackground(Void... devices) //while the progress dialog is shown, the connection is done in background
180 | {
181 | try
182 | {
183 | if (btSocket == null || !isBtConnected)
184 | {
185 | myBluetooth = BluetoothAdapter.getDefaultAdapter();//get the mobile bluetooth device
186 | BluetoothDevice dispositivo = myBluetooth.getRemoteDevice(address);//connects to the device's address and checks if it's available
187 | btSocket = dispositivo.createInsecureRfcommSocketToServiceRecord(myUUID);//create a RFCOMM (SPP) connection
188 | BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
189 | btSocket.connect();//start connection
190 | }
191 | }
192 | catch (IOException e)
193 | {
194 | ConnectSuccess = false;//if the try failed, you can check the exception here
195 | }
196 | return null;
197 | }
198 | @Override
199 | protected void onPostExecute(Void result) //after the doInBackground, it checks if everything went fine
200 | {
201 | super.onPostExecute(result);
202 |
203 | if (!ConnectSuccess)
204 | {
205 | msg("Connection Failed. Is it a SPP Bluetooth? Try again.");
206 | finish();
207 | }
208 | else
209 | {
210 | msg("Connected.");
211 | isBtConnected = true;
212 | }
213 | progress.dismiss();
214 | }
215 | }
216 | }
217 |
--------------------------------------------------------------------------------
/LED-master/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------