Serial Communication Using Android Phone

 click here for Youtube Video

For accesing through your android download any serial terminal for android from playstore.

Arduino Code

 
 
int x;  
void setup() 
  { 
     
 
pinMode(7,OUTPUT); //set particular pin as output or input 
pinMode(6,OUTPUT); 
pinMode(5,OUTPUT); 
pinMode(4,OUTPUT); 
digitalWrite(7,LOW); 
digitalWrite(6,LOW); 
digitalWrite(5,LOW); 
digitalWrite(4,LOW); 
  Serial.begin(19200);   // opens serial port, sets data rate to 9600 bps 
  } 
 
 
  void loop() 
  { 
  if (Serial.available() > 0) 
  { 
    // read the incoming byte: 
   char x = Serial.read(); 
     
    switch(x) 
    { 
       
      case '0':            // stop 
       digitalWrite(7,LOW); 
       digitalWrite(6,LOW); 
       digitalWrite(5,LOW); 
       digitalWrite(4,LOW); 
       break; 
 
      
       
      case '6':         // sharp right 
       digitalWrite(7,HIGH); 
       digitalWrite(6,LOW); 
      digitalWrite(5,LOW); 
      digitalWrite(4,LOW); 
      break; 
 
      case'5':        //backward 
       digitalWrite(7,LOW); 
       digitalWrite(6,HIGH); 
      digitalWrite(5,HIGH); 
      digitalWrite(4,LOW); 
      break; 
 
      case'4':                //sharp left 
       digitalWrite(7,LOW);            
       digitalWrite(6,LOW); 
       digitalWrite(5,LOW); 
      digitalWrite(4,HIGH); 
      break; 
 
       case'8':        //forward 
      digitalWrite(7,HIGH); 
      digitalWrite(6,LOW); 
      digitalWrite(5,LOW); 
       digitalWrite(4,HIGH); 
       break; 
       case'9'://rotate 
       digitalWrite(7,LOW); 
       digitalWrite(6,HIGH); 
      digitalWrite(5,LOW); 
      digitalWrite(4,HIGH); 
      break; 
  
 
       
       
       
    } 
  } 
 }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s