Bluetooth Android ArduinoMega

Bluetooth Android ArduinoMega Free App

Rated 5.00/5 (3) —  Free Android application by Vinemacc

About Bluetooth Android ArduinoMega

Source Arduino Mega:
/*
PROJECT: ArduDroid
PROGRAMMER: Nguyen Huu Long (vnns.vn)
DATE: Dec 15, 2015
FILE: ardudroid.ino
LICENSE: Public domain
*/
#define START_CMD_CHAR '*'
#define END_CMD_CHAR '#'
#define DIV_CMD_CHAR '|'
#define CMD_DIGITALWRITE 10
#define CMD_ANALOGWRITE 11
#define CMD_TEXT 12
#define CMD_READ_ARDUDROID 13
#define MAX_COMMAND 20 // max command number code. used for error checking.
#define MIN_COMMAND 10 // minimum command number code. used for error checking.
#define IN_STRING_LENGHT 40
#define MAX_ANALOGWRITE 255
#define PIN_HIGH 3
#define PIN_LOW 2
String inText;

void setup() {
Serial.begin(9600);
Serial.println("ArduDroid 0.1 Alpha by vnns.vn (2015)");
Serial.flush();
}

void loop()
{
Serial.flush();
int ard_command = 0;
int pin_num = 0;
int pin_value = 0;
char get_char = ' '; //read serial

// wait for incoming data
if (Serial.available() < 1) return; // if serial empty, return to loop().

// parse incoming command start flag
get_char = Serial.read();
if (get_char != START_CMD_CHAR) return; // if no command start flag, return to loop().

// parse incoming command type
ard_command = Serial.parseInt(); // read the command

// parse incoming pin# and value
pin_num = Serial.parseInt(); // read the pin
pin_value = Serial.parseInt(); // read the value

// 1) GET TEXT COMMAND FROM ARDUDROID
if (ard_command == CMD_TEXT){
inText =""; //clears variable for new input
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
delay(5);
if (c == END_CMD_CHAR) { // if we the complete string has been read
// add your code here
break;
}
else {
if (c != DIV_CMD_CHAR) {
inText += c;
delay(5);
}
}
}
}
// 2) GET digitalWrite DATA FROM ARDUDROID
if (ard_command == CMD_DIGITALWRITE){
if (pin_value == PIN_LOW) pin_value = LOW;
else if (pin_value == PIN_HIGH) pin_value = HIGH;
else return; // error in pin value. return.
set_digitalwrite( pin_num, pin_value); // Uncomment this function if you wish to use
return; // return from start of loop()
}

// 3) GET analogWrite DATA FROM ARDUDROID
if (ard_command == CMD_ANALOGWRITE) {
analogWrite( pin_num, pin_value );
// add your code here
return; // Done. return to loop();
}

// 4) SEND DATA TO ARDUDROID
if (ard_command == CMD_READ_ARDUDROID) {
// char send_to_android[] = "Place your text here." ;
// Serial.println(send_to_android); // Example: Sending text
Serial.print(" Analog 0 = ");
Serial.println(analogRead(A0)); // Example: Read and send Analog pin value to Arduino
return; // Done. return to loop();
}
}

// 2a) select the requested pin# for DigitalWrite action
void set_digitalwrite(int pin_num, int pin_value)
{
pinMode(pin_num, OUTPUT);
digitalWrite(pin_num, pin_value);
}

How to Download / Install

Download and install Bluetooth Android ArduinoMega version 1.0 on your Android device!
Downloaded 100+ times, content rating: Not rated
Android package: vnns.vn.appbluetooth, download Bluetooth Android ArduinoMega.apk

All Application Badges

Free
downl.
Android
2.2+
n/a
Not
rated
Android app

App History & Updates

More downloads  Bluetooth Android ArduinoMega reached 100 - 500 downloads

Oh snap! No comments are available for Bluetooth Android ArduinoMega at the moment. Be the first to leave one!

Share The Word!


Rating Distribution

RATING
5.05
3 users

5

4

3

2

1