2017년 3월 29일 수요일

Course on MIT App Inventor and Arduino by Magesh Jayakumar in 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>


SoftwareSerial BT(10, 11); //TX, RX respetively
String state;// string to store incoming message from bluetooth


void setup() {
 BT.begin(9600);// bluetooth serial communication will happen on pin 10 and 11
 Serial.begin(9600); // serial communication to check the data on serial monitor
  pinMode(13, OUTPUT); // LED connected to 13th pin




}
//-----------------------------------------------------------------------//  
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
  state += c; //build the string- either "On" or "off"
  }  
  if (state.length() > 0) {
    Serial.println(state); 


  if(state == "turn on") 
  {
    digitalWrite(13, HIGH);
    
      } 
  
  else if(state == "turn off") 
  {
    digitalWrite(13, LOW);
     }
  
  
state ="";}} //Reset the variable


</softwareserial.h>
Step 1: 2. Android Arduino Speech Recognition Ap
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.
Step 2: 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  // TX RX software library for bluetooth


#include  // 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
  }




}







Step 3: 4. Make a Android Arduino Robot

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 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

Step 4: 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.

Step 5: 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

댓글 없음:

댓글 쓰기