Bluetooth HC-05 & ArduDroid - Hello World


device: arduino uno

i think have hc-05 working , wired correctly. able launch ardudroid , connect hc-05 , can see name come "kevin test: in test data area of app:


the problem think not able send data or control led light (in below picture). can see red wire plugged positive terminal of red led pin 11 on arduino. the problem in ardudroid app when slide bar 11 in app, led light not responding. there test can send data hc-05 make light blink or send message app terminal window in arduino application on pc? know led wired correctly, able modify code in test make manually blink on pin 11.



here original wiring diagram followed except had daisychain 2 1k resistors , didnt put resistor on led ground because running 3.3 volts through board , wont have led on long anyway.


here tutorial , code used
http://www.techbitar.com/ardudroid-simple-bluetooth-control-for-arduino-and-android.html
code: [select]
/*
project: ardudroid
programmer: hazim bitar (techbitar @ gmail dot com)
date: oct 31, 2013
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 error checking.
#define min_command 10  // minimum command number code. used 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.12 alpha techbitar (2013)");
 serial.flush();
}

void loop()
{
 serial.flush();
 int ard_command = 0;
 int pin_num = 0;
 int pin_value = 0;

 char get_char = ' ';  //read serial

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

 // parse incoming command start flag
 get_char = serial.read();
 if (get_char != start_cmd_char) return; // if no command start flag, return loop().

 // parse incoming command type
 ard_command = serial.parseint(); // read command
 
 // parse incoming pin# , value  
 pin_num = serial.parseint(); // read pin
 pin_value = serial.parseint();  // read value

 // 1) text command ardudroid
 if (ard_command == cmd_text){  
   intext =""; //clears variable new input  
   while (serial.available())  {
     char c = serial.read();  //gets 1 byte serial buffer
     delay(5);
     if (c == end_cmd_char) { // if complete string has been read
       // add code here
       break;
     }              
     else {
       if (c !=  div_cmd_char) {
         intext += c;
         delay(5);
       }
     }
   }
 }

 // 2) digitalwrite data 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 function if wish use
   return;  // return start of loop()
 }

 // 3) analogwrite data ardudroid
 if (ard_command == cmd_analogwrite) {  
   analogwrite(  pin_num, pin_value );
   // add code here
   return;  // done. return loop();
 }

 // 4) send data ardudroid
 if (ard_command == cmd_read_ardudroid) {
   // char send_to_android[] = "place text here." ;
   // serial.println(send_to_android);   // example: sending text
   serial.print(" analog 0 = ");
   serial.println(analogread(a0));  // example: read , send analog pin value arduino
   return;  // done. return loop();
 }
}

// 2a) select requested pin# digitalwrite action
void set_digitalwrite(int pin_num, int pin_value)
{
 switch (pin_num) {
 case 13:
   pinmode(13, output);
   digitalwrite(13, pin_value);  
   // add code here      
   break;
 case 12:
   pinmode(12, output);
   digitalwrite(12, pin_value);  
   // add code here      
   break;
 case 11:
   pinmode(11, output);
   digitalwrite(11, pin_value);        
   // add code here
   break;
 case 10:
   pinmode(10, output);
   digitalwrite(10, pin_value);        
   // add code here
   break;
 case 9:
   pinmode(9, output);
   digitalwrite(9, pin_value);        
   // add code here
   break;
 case 8:
   pinmode(8, output);
   digitalwrite(8, pin_value);        
   // add code here
   break;
 case 7:
   pinmode(7, output);
   digitalwrite(7, pin_value);        
   // add code here
   break;
 case 6:
   pinmode(6, output);
   digitalwrite(6, pin_value);        
   // add code here
   break;
 case 5:
   pinmode(5, output);
   digitalwrite(5, pin_value);
   // add code here      
   break;
 case 4:
   pinmode(4, output);
   digitalwrite(4, pin_value);        
   // add code here
   break;
 case 3:
   pinmode(3, output);
   digitalwrite(3, pin_value);        
   // add code here
   break;
 case 2:
   pinmode(2, output);
   digitalwrite(2, pin_value);
   // add code here      
   break;      
   // default:
   // if nothing else matches, default
   // default optional
 }
}

did much?

in short, able connect hc-05 via bluetooth, can see code sending information arduino sketch phone via bluetooth (ardudroid app), led light wired properly... seems can not send commands.... slider bars , toggle button not turn led light on. ideas?


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Bluetooth HC-05 & ArduDroid - Hello World


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support