Friday, April 29, 2016

1.Getting Started with Arduino and Android

Can make their own app and control a LED connected to arduino without any prior experience, if they have components with that's more enough to make this tutorial. Blinking an LED is the first thing we do when we getting started with electronics in this tutorial you will TURN ON and TURN OFF the LED, this is the Hello world example in this tutorial, you don't need any prior coding experience to make this application work. To test the app that created during this tutorial, you need an Android mobile or android supported devices to test your app. creating an app with MIT app inventor is very simple, you won't be doing any coding process during creating your app, you will be assembling blocks together to make your app. if you don't have any prior experience with Arduino control, make sure you follow some basics like connecting Arduino to your computer and upload example code to Arduino from Arduino IDE, this would be more sufficient to follow this tutorial.
--------------------------------------------------------------------------------------------------------------------------
#include <SoftwareSerial.h>
String state;// string to store incoming message from bluetooth
void setup() {
  Serial.begin(9600); // serial communication started
  pinMode(13, OUTPUT); // LED connected to 13th pin


}
//-----------------------------------------------------------------------//  
void loop() {
  while (Serial.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable 
  char c = Serial.read(); //Conduct a serial read
  state += c; //build the string- either "On" or "off"
  }  
  if (state.length() > 0) {
    
  if(state == "on") 
  {
    digitalWrite(13, HIGH);
    
      } 
  
  else if(state == "off") 
  {
    digitalWrite(13, LOW);
     }

state ="";} //Reset the variable
}





--------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment