2017년 3월 29일 수요일

Course on MIT app inventor Arduino


I have made many tutorials for creating apps using MIT app inventor and connected the app with arduino to make things work, I often get email stating something went missing when they follow my tutorial, Here's a step by step tutorial on getting started with creating MIT app inventor and control things with arduino. To complete this tutorial you need a Bluetooth module HC-05 or HC-06 to connect with arduino and send or receive data to and from other Bluetooth device. 

Lets Make our first app to control an LED

  1.Getting Started with Arduino and Android 




This video gives insight into MIT app inventor and what are the requirements need to get started with this video series, anyone watching this video 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
}

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

  2. Android Arduino Speech recognition app.  




In this tutorial you will know how to create a speech recognition app that will convert your speech to text and send command to your arduino and do certain task that matches your command, you don't have any control over the speech to text conversion process, it is entirely depend on the google speech to text conversion engine, we will be making use of the speech to conversion process in this app, when the process of getting converting the text is over we will be sending the converted command to Arduino. You also need internet connectivity to do this process because google speech to conversion engine depends on Internet connectivity to do this you cannot do this process offline, you need to be connected with internet when following and working this tutorial. once you complete this app you can use this for many applications including Home Automation, Controlling a Bluetooth robot, sending voice command to do a process there are many possibilities with this application. The same hardware what you have created previous tutorial is enough for this tutorial you don't need to change your hardware connection to make this work. keep your hardware same connect this app to your arduino and start to send your command.

  3. Servo Motor control using Arduino and Android  




In this tutorial you will be creating an app for controlling a servo motor, you will be using slider in your app to move your servo from 0-180, You need a servo motor to be connected on arduino side, make sure you also connecting external powersupply so that your Arduino will not restart during this process,
 --------------------------------------------------------------------------------------------------------------------------

#include <SoftwareSerial.h> // TX RX software library for bluetooth

#include <Servo.h> // servo library 
Servo myservo; // servo name

int bluetoothTx = 10; // bluetooth tx to 10 pin
int bluetoothRx = 11; // bluetooth rx to 11 pin

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  myservo.attach(9); // attach servo signal wire to pin 9
  //Setup usb serial connection to computer
  Serial.begin(9600);

  //Setup Bluetooth serial connection to android
  bluetooth.begin(9600);
}

void loop()
{
  //Read from bluetooth and write to usb serial
  if(bluetooth.available()> 0 ) // receive number from bluetooth
  {
    int servopos = bluetooth.read(); // save the received number to servopos
    Serial.println(servopos); // serial print servopos current number received from bluetooth
    myservo.write(servopos); // roate the servo the angle received from the android app
  }


}


-------------------------------------------------------------------------------------------------------------------------- 
4. Make a Android Arduino Robot  




In this tutorial you will be learning on how to make an app for controlling an robot by android app, you will be using android phone as remote controller to control the robot. You need 2 gear motor with wheels A motor driver, you can use any of the motor driver you want, I used L293D motor driver for this project. You also need a battery and connecting wires, apart from that as usual a Bluetooth and Arduino board is needed to complete this tutorial.
-------------------------------------------------------------------------------------------------------------------------- 
#include <SoftwareSerial.h>

SoftwareSerial BT(10, 11); //TX, RX respetively
String readdata;

void setup() {
 BT.begin(9600);
 Serial.begin(9600);
  pinMode(3, OUTPUT); // connect to input 1 of l293d
  pinMode(4, OUTPUT); // connect to input 4 of l293d
  pinMode(5, OUTPUT); // connect to input 3 of l293d
  pinMode(6, OUTPUT); // connect to input 2 of l293d

}
//-----------------------------------------------------------------------// 
void loop() {
  while (BT.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable
  char c = BT.read(); //Conduct a serial read
  readdata += c; //build the string- "forward", "reverse", "left" and "right"
  } 
  if (readdata.length() > 0) {
    Serial.println(readdata); // print data to serial monitor
// if data received as forward move robot forward
  if(readdata == "forward") 
  {
    digitalWrite(3, HIGH);
    digitalWrite (4, HIGH);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    delay(100);
  }
  // if data received as reverse move robot reverse

  else if(readdata == "reverse")
  {
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
    digitalWrite(6,HIGH);
    delay(100);
  }
// if data received as right turn robot to right direction.
  else if (readdata == "right")
  {
    digitalWrite (3,HIGH);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    delay (100);
   
  }
// if data received as left turn robot to left direction
 else if ( readdata == "left")
 {
   digitalWrite (3, LOW);
   digitalWrite (4, HIGH);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
 }
 // if data received as stop, halt the robot

 else if (readdata == "stop")
 {
   digitalWrite (3, LOW);
   digitalWrite (4, LOW);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
 }

  


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

-------------------------------------------------------------------------------------------------------------------------- 5. Know your Home Temperature and Humidity creating an Android app 

There are many app and widget floating market for knowing outside temperature and humidity, but there are no app that can provide your Temperature and Humidity inside your home, by creating this app you can retrieve temperature and humidity data from arduino.




By following the above tutorial you can make your own app that display temperature and humidity data as well as this app will make you hear what is the current temperature and humidity at your home. for this project I used DHT11 sensor with arduino to export temperature data to my android app, similarly you can use any Temperature sensor like DHT22 or DHT23 or DHT33 or one wire ds180b20 type of sensor can be used to replicate the same project. 

6. Android Arduino Speech recognition bot.


This app combines tutorial 2 and 4 to make a new project, as we discussed earlier that speech to text conversion app can be used for many projects, this is one of the application of that app, we using the same for the robot we created during our 4th lesson. This follows same hardware and all the codes are same make the robot and have fun. 
if you had so much during all your learning and want to explore additional things you can check the book here

please leave your suggestion and queries to this mail id jayakumarmagesh@gmail.com


RGB Slider Color Selector RGB LED | Android and Arduino

This post is about choosing color for the RGB LED light from the android app, I used slider to control the LED colors.


Circuit Diagram for common anode RGB LED:


Circuit Diagram for common cathode RGB LED:


components needed for this project:
Arduino Uno
RGB LED
Bluetooth Module
Connecting Wires
Breadboard 

Android app created using MIT app inventor, which is very simple, 3 sliders had created to assign values of primary colors RGB, when these sliders are moved these different colors are mixed and shown in the canvas, same color code will be send to the arduino. 

Android app: 

android app can be download from this link

Blocks to create Android app:








Arduino Program to control Common anode LED: 

#include <SoftwareSerial.h>

int bluetoothTx = 7;
int bluetoothRx = 8;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
 pinMode(3,OUTPUT); // blue pin of RGB LED
 pinMode(5,OUTPUT); // Green pin of RGB LED
 pinMode(6,OUTPUT); // Red pin of RGB LED

 digitalWrite(3,HIGH);
 digitalWrite(5,HIGH);
 digitalWrite(6,HIGH);
  //Setup usb serial connection to computer
  Serial.begin(9600);

  //Setup Bluetooth serial connection to android
  bluetooth.begin(9600);
}

void loop()
{
  //Read from bluetooth and write to usb serial
  if(bluetooth.available()>= 2 )
  {
    unsigned int color1 = bluetooth.read();
    unsigned int color2 = bluetooth.read();
    unsigned int color = (color2 *256) + color1;
    Serial.println(color);
 
    if (color >= 1000 && color <1255){
    int blue = color;
    blue = map(blue, 1000,1255,0,255);
    int blue1 = 255-blue;
    analogWrite(6,blue1);
    Serial.println(blue1);
    delay(10);

    }
 
    if (color >=2000 && color <2255){
      int green = color;
      green = map(green,2000,2255,0,255);
      int green1 = 255 - green;
      analogWrite(5,green1);
      Serial.println(green1);
      delay(10);
   
    }
 
    if (color >=3000 && color < 3255){
      int red = color;
      red = map(red, 3000, 3255,0,255);
      int red1 = 255 - red;
      analogWrite(3,red1);
      Serial.println(red1);
      delay(10);
    }
 

  }


}

Arduino program for common cathode RGB LED:

#include <SoftwareSerial.h>

int bluetoothTx = 7;
int bluetoothRx = 8;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
 pinMode(3,OUTPUT); // blue pin of RGB LED
 pinMode(5,OUTPUT); // Green pin of RGB LED
 pinMode(6,OUTPUT); // Red pin of RGB LED

 digitalWrite(3,LOW);
 digitalWrite(5,LOW);
 digitalWrite(6,LOW);
  //Setup usb serial connection to computer
  Serial.begin(9600);

  //Setup Bluetooth serial connection to android
  bluetooth.begin(9600);
}

void loop()
{
  //Read from bluetooth and write to usb serial
  if(bluetooth.available()>= 2 )
  {
    unsigned int color1 = bluetooth.read();
    unsigned int color2 = bluetooth.read();
    unsigned int color = (color2 *256) + color1;
    Serial.println(color);
 
    if (color >= 1000 && color <1255){
    int blue = color;
    blue = map(blue, 1000,1255,0,255);
    analogWrite(6,blue);
    Serial.println(blue);
    delay(10);

    }
 
    if (color >=2000 && color <2255){
      int green = color;
      green = map(green,2000,2255,0,255);
      analogWrite(5,green);
      Serial.println(green);
      delay(10);
   
    }
 
    if (color >=3000 && color < 3255){
      int red = color;
      red = map(red, 3000, 3255,0,255);
      analogWrite(3,red);
      Serial.println(red);
      delay(10);
    }
 

  }


}

Saturday, May 23, 2015


Control stepper Motor from android app




Stepper Motor controlled from Android, the android app created using MIT app inventor. This app will only work for Easydriver for stepper motor, other stepper control will not work with this app.




Checkout the video to know how the app control stepper motor, this is a very simple stepper control application which you can make and understand how to control a stepper motor from android.


Arduino code for controlling stepper motor from android app:
-------------------------------------------------------------------------------------------------------------------------------

#include <AccelStepper.h>

AccelStepper stepper(AccelStepper::FULL2WIRE, 8, 9);

int spd = 1000;    // The current speed in steps/second
int sign = 1;      // Either 1, 0 or -1

void setup()
{
  Serial.begin(9600);
  stepper.setMaxSpeed(1000);
  stepper.setSpeed(1000);
}

void loop()
{
  char c;
  if(Serial.available()) {
    c = Serial.read();
    if (c == 'f') {  // forward
      sign = 1;
    }
    if (c == 'r') {  // reverse
      sign = -1;
    }
    if (c == 's') {  // stop
      sign = 0;
    }
    if (c == '1') {  // super slow
      spd = 10;
    }
    if (c == '2') {  // slow
      spd = 100;
    }
    if (c == '3') {  // medium
      spd = 300;
    }
       if (c == '4') {  // Fast
      spd = 500;
    }

       if (c == '5') {  // medium
      spd = 700;
    }

       if (c == '6') {  // medium
      spd = 1000;
    }
    stepper.setSpeed(sign * spd);
  }
  stepper.runSpeed();
}

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

Android app link click here

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


MIT app inventor blocks:




Control Multiple servo motors using Arduino and Android app




Hi are you looking to control More than one servo motor using android app, if then this is a perfect place for you to find your exact requirement.

I created an android app using MIT app inventor 2 , I created this app to control 6 servo motor using android and arduino, I have arduino uno, which has only 6 PWM pins that's the reason I created 6 servo control, If you want to control more than 6 you can use arduino Mega to do this.

Please click the link  here

what are the components you need for this?
N number of servo motors
Arduino
Android Mobile or Tab
Connecting Wires
Bluetooth Device (HC-05 or HC-06) I used HC-06 for this project

You can find the Circuit Diagram for this project above. Connect your servo according to that, If possible power the Servos and arduino separately

you can find the arduino program in the video, if you want arduino file , download here

Check the video below to know How to make mit app for controlling multiple stepper motor.


Here's a step by step Tutorial For Making an android app using MIT app inventor for controlling a arduino robot through bluetooth. 

There are many app available in the android store to use with arduino and other microcontrollers but you may encounter with many adds and spam and we are bound to accept the licence agreement with the developer where we may share many vital information from our device. so how can we eliminate the use of using 3rd party apps for our own project?

Yeah there is a solution for this to create our own app where we don't need to worry about sharing our personal information with the original app developer.


Follow the video to make your own app to control your gadgets and robot. check the other videos for how to control electrical devices and other appliances by making your own Android app using MIT app inventor and controlling devices through arduino or other microcontroller.

How to Make Android app using MIT app inventor to control a Servo Motor


If you are looking to make Android app to control a servo motor, this is a perfect blog post for you, here you can follow a step by step procedure video to know how to make an android app using MIT app inventor and to control a servo motor. This app sends the angle for the servo from your android phone to your bluetooth connected to the Arduino. where the Arduino receives the angle and executes the program and set the angle to the servo motor.


What components that you need to make this?
Arduino Uno or any other microcontroller.
servo Motor
Bluetooth Module (HC-05)
Android phone :)



After completing the Program in MIT app inventor, go to Build and select App( save .apk to my computer)

Transfer the file to your android mobile phone or tablet.

if your mobile not allowing to install the app from unknown sources.

go to setting in your android mobile select security and move to Device administration and give access to allow install app from unknown sources.



Arduino Program:
___________________________________________________________________________________

#include <SoftwareSerial.h>

#include <Servo.h> 
Servo myservo;

int bluetoothTx = 10;
int bluetoothRx = 11;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  myservo.attach(9);
  //Setup usb serial connection to computer
  Serial.begin(9600);

  //Setup Bluetooth serial connection to android
  bluetooth.begin(9600);
}

void loop()
{
  //Read from bluetooth and write to usb serial
  if(bluetooth.available()> 0 )
  {
    int servopos = bluetooth.read();
    Serial.println(servopos); 
    myservo.write(servopos);
  }


}

___________________________________________________________________________________

댓글 1개:

  1. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.
    How to make an app

    답글삭제