Friday 2 March 2018

Mouse Controlled Arduino LEDS blinking

Mouse Controlling Arduino LEDs


Use a mouse to control LEDs Connected to an Arduino.pelase following the steps



Required of Components 

Arduino UNO
  1. Breadboard
  2. 9 LEDs
  3. 9 x 330 ohm resistors
  4. Wires to connect the circuit
  5. USB connection cable: to connect the computer to the Arduino
  6. A computer: to run the processing sketch, and to compile / upload the Arduino sketch
  7. Processing Program installed on computer
  8. Arduino Program installed on the computer

Diagram





Sourcre Code

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* This program was created by ScottC on 9/5/2012 to receive serial 
signals from a computer to turn on/off  1-9 LEDs */

void setup() {                
  // initialize the digital pins as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
// Turn the Serial Protocol ON
  Serial.begin(9600);
}

void loop() {
  byte byteRead;

   /*  check if data has been sent from the computer: */
  if (Serial.available()) {
  
    /* read the most recent byte */
    byteRead = Serial.read();
    //You have to subtract '0' from the read Byte to convert from text to a number.
    byteRead=byteRead-'0';
    
    //Turn off all LEDS
    for(int i=2; i<11; i++){
      digitalWrite(i, LOW);
    }
    
    if(byteRead>0){
      //Turn on the relevant LEDs
      for(int i=1; i<(byteRead+1); i++){
        digitalWrite(i+1, HIGH);
      }
    }
  }
}

.......................................................................................................................................................

Processing  Code :


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//Created by ScottC on  send mouse coordinates to Arduino

import processing.serial.*;

// Global variables
int new_sX, old_sX;
int nX, nY;
Serial myPort;

// Setup the Processing Canvas
void setup(){
  size( 800, 400 );
  strokeWeight( 10 );
 
  //Open the serial port for communication with the Arduino
  //Make sure the COM port is correct
  myPort = new Serial(this, "COM6", 9600);
  myPort.bufferUntil('\n'); 
}

// Draw the Window on the computer screen
void draw(){
  
  // Fill canvas grey
  background( 100 );
    
  // Set the stroke colour to white
  stroke(255); 
  
  // Draw a circle at the mouse location
  ellipse( nX, nY, 10, 10 );

  //Draw Line from the top of the page to the bottom of the page
  //in line with the mouse.
  line(nX,0,nX,height);  
}


// Get the new mouse location and send it to the arduino
void mouseMoved(){
  nX = mouseX;
  nY = mouseY; 
  
  //map the mouse x coordinates to the LEDs on the Arduino.
  new_sX=(int)map(nX,0,800,0,10);

  if(new_sX==old_sX){
    //do nothing
  } else {
    //only send values to the Arduino when the new X coordinates are different.
    old_sX = new_sX;
    myPort.write(""+new_sX);
  }
}

.....................................................................................................................................................



Arduino Tutorial : LED Sequential Control with Arduino

LED Sequential Control Beginner Project 





Components Required


  • Arduino Uno
  • Bread board
  • USB Cable
  • Jumper Wires
  • 3 LEDs ( Different Colors )
  • 3 Resisters ( 220 ohm each )

Connect the Circuit


To connect ground to do this use a jumper wire to connect the ground pin on the arduino to the negative rail on the breadboard this allows all the LEDs to use the ground pin on the Arduino


Step2 


To insert the resistors into the breadboard space the resistors out with one leg connected to the negative rail on the breadboard





Step 3


insert the LEDs The longest pin is the positive (+) and the shortest pin is the negative(-). If it is wired the wrong way it will not operation






R = (5V – 3.3V) / 0.015

R = 113 ohm’s

We'll use the closest resistor value of 100 ohms.


source code :


int led = 13;
int led2 = 12;
int led3 = 11;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(100);
{digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);}
{digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
delay(100);}// wait for a second
}

...........................................................................................................................................................


More projects:


Thursday 1 March 2018

Arduino Based CNC Machine Made from old DVD writer

HOW TO MAKE ARDUINO BASED CNC MACHINE using DVD writer AT HOME






Requiredments

1)Arduino Nano x1

2)Old DVD writer x2

3)Motor Driver (L293D) x2

4)16 pin IC socket x2

5) Veroboard doted x1 or you can make pcb

6)Male header & Female header

7)Female USB (For power the motors) or you can use 9v jack


8)Female Jumper wires

9) Nuts

10) BO motor clamp

11)1 Servo motor

12) Double sided tape


13)Pen

14)Acrylic sheet


Acrylic Sheet  Cutting and Drilling 







1pcs 12"x6" (Fore base)

2pcs 1.5"x7" (For X-Axis Stand)

1pcs 3"x3" (For Writing base)

3pcs 1.5"x3"(For Moving part of X-Axis & Y-Axis and also for pen holder)

8pcs .5"x,5" (For specer)

Marke for drilling then drill it


Extracted Old DVD Writer





Extracting  X-Axis and Y-Axis From Old DVD Writer and  Solding the  Wire With Stepper Motor






Attach 1.5"x 3" Sheet With Moving Part of X and Y-Axis by Using Glue Gun






following Circuit Board





Makeing a Pen Holder


Broken  DVD writer Shuter Mechanism

Attach Servo and connect with the Gear

Connect  sheet with moving part and also glue the pencil compass to hold the pen



Assemblying full parts





Board with connections following steps




Arduino Code for CNC Machine:


how To download and Use Arduino Uno Software under Windows

........................................................................................................................
#include <Servo.h>
#include <AFMotor.h>
#define LINE_BUFFER_LENGTH 512
char STEP = MICROSTEP ;
// Servo position for Up and Down
const int penZUp = 115;
const int penZDown = 83;
// Servo on PWM pin 10
const int penServoPin =10 ;
// Should be right for DVD steppers, but is not too important here
const int stepsPerRevolution = 48; 
// create servo object to control a servo
Servo penServo;  
// Initialize steppers for X- and Y-axis using this Arduino pins for the L293D H-bridge
AF_Stepper myStepperY(stepsPerRevolution,1);          
AF_Stepper myStepperX(stepsPerRevolution,2);  
/* Structures, global variables    */
struct point {
  float x;
  float y;
  float z;
};
// Current position of plothead
struct point actuatorPos;
//  Drawing settings, should be OK
float StepInc = 1;
int StepDelay = 0;
int LineDelay =0;
int penDelay = 50;
// Motor steps to go 1 millimeter.
// Use test sketch to go 100 steps. Measure the length of line.
// Calculate steps per mm. Enter here.
float StepsPerMillimeterX = 100.0;
float StepsPerMillimeterY = 100.0;
// Drawing robot limits, in mm
// OK to start with. Could go up to 50 mm if calibrated well.
float Xmin = 0;
float Xmax = 40;
float Ymin = 0;
float Ymax = 40;
float Zmin = 0;
float Zmax = 1;
float Xpos = Xmin;
float Ypos = Ymin;
float Zpos = Zmax; 
// Set to true to get debug output.
boolean verbose = false;
//  Needs to interpret
//  G1 for moving
//  G4 P300 (wait 150ms)
//  M300 S30 (pen down)
//  M300 S50 (pen up)
//  Discard anything with a (
//  Discard any other command!
/**********************
 * void setup() - Initialisations
 ***********************/
void setup() {
  //  Setup

  Serial.begin( 9600 );

  penServo.attach(penServoPin);
  penServo.write(penZUp);
  delay(100);
  // Decrease if necessary
  myStepperX.setSpeed(600);
  myStepperY.setSpeed(600);

  //  Set & move to initial default position
  // TBD
  //  Notifications!!!
  Serial.println("Mini CNC Plotter alive and kicking!");
  Serial.print("X range is from ");
  Serial.print(Xmin);
  Serial.print(" to ");
  Serial.print(Xmax);
  Serial.println(" mm.");
  Serial.print("Y range is from ");
  Serial.print(Ymin);
  Serial.print(" to ");
  Serial.print(Ymax);
  Serial.println(" mm.");
}
/**********************
 * void loop() - Main loop
 ***********************/
void loop()
{

  delay(100);
  char line[ LINE_BUFFER_LENGTH ];
  char c;
  int lineIndex;
  bool lineIsComment, lineSemiColon;
  lineIndex = 0;
  lineSemiColon = false;
  lineIsComment = false;
  while (1) {
    // Serial reception - Mostly from Grbl, added semicolon support
    while ( Serial.available()>0 ) {
      c = Serial.read();
      if (( c == '\n') || (c == '\r') ) {             // End of line reached
        if ( lineIndex > 0 ) {                        // Line is complete. Then execute!
          line[ lineIndex ] = '\0';                   // Terminate string
          if (verbose) {
            Serial.print( "Received : ");
            Serial.println( line );
          }
          processIncomingLine( line, lineIndex );
          lineIndex = 0;
        }
        else {
          // Empty or comment line. Skip block.
        }
        lineIsComment = false;
        lineSemiColon = false;
        Serial.println("ok");  
      }
      else {
        if ( (lineIsComment) || (lineSemiColon) ) {   // Throw away all comment characters
          if ( c == ')' )  lineIsComment = false;     // End of comment. Resume line.
        }
        else {
          if ( c <= ' ' ) {                           // Throw away whitepace and control characters
          }
          else if ( c == '/' ) {                    // Block delete not supported. Ignore character.
          }
          else if ( c == '(' ) {                    // Enable comments flag and ignore all characters until ')' or EOL.
            lineIsComment = true;
          }
          else if ( c == ';' ) {
            lineSemiColon = true;
          }
          else if ( lineIndex >= LINE_BUFFER_LENGTH-1 ) {
            Serial.println( "ERROR - lineBuffer overflow" );
            lineIsComment = false;
            lineSemiColon = false;
          }
          else if ( c >= 'a' && c <= 'z' ) {        // Upcase lowercase
            line[ lineIndex++ ] = c-'a'+'A';
          }
          else {
            line[ lineIndex++ ] = c;
          }
        }
      }
    }
  }
}
void processIncomingLine( char* line, int charNB ) {
  int currentIndex = 0;
  char buffer[ 64 ];                                 // Hope that 64 is enough for 1 parameter
  struct point newPos;
  newPos.x = 0.0;
  newPos.y = 0.0;
  //  Needs to interpret
  //  G1 for moving
  //  G4 P300 (wait 150ms)
  //  G1 X60 Y30
  //  G1 X30 Y50
  //  M300 S30 (pen down)
  //  M300 S50 (pen up)
  //  Discard anything with a (
  //  Discard any other command!
  while( currentIndex < charNB ) {
    switch ( line[ currentIndex++ ] ) {              // Select command, if any
    case 'U':
      penUp();
      break;
    case 'D':
      penDown();
      break;
    case 'G':
      buffer[0] = line[ currentIndex++ ];          // /!\ Dirty - Only works with 2 digit commands
      //      buffer[1] = line[ currentIndex++ ];
      //      buffer[2] = '\0';
      buffer[1] = '\0';
      switch ( atoi( buffer ) ){                   // Select G command
      case 0:                                   // G00 & G01 - Movement or fast movement. Same here
      case 1:
        // /!\ Dirty - Suppose that X is before Y
        char* indexX = strchr( line+currentIndex, 'X' );  // Get X/Y position in the string (if any)
        char* indexY = strchr( line+currentIndex, 'Y' );
        if ( indexY <= 0 ) {
          newPos.x = atof( indexX + 1);
          newPos.y = actuatorPos.y;
        }
        else if ( indexX <= 0 ) {
          newPos.y = atof( indexY + 1);
          newPos.x = actuatorPos.x;
        }
        else {
          newPos.y = atof( indexY + 1);
          indexY = '\0';
          newPos.x = atof( indexX + 1);
        }
        drawLine(newPos.x, newPos.y );
        //        Serial.println("ok");
        actuatorPos.x = newPos.x;
        actuatorPos.y = newPos.y;
        break;
      }
      break;
    case 'M':
      buffer[0] = line[ currentIndex++ ];        // /!\ Dirty - Only works with 3 digit commands
      buffer[1] = line[ currentIndex++ ];
      buffer[2] = line[ currentIndex++ ];
      buffer[3] = '\0';
      switch ( atoi( buffer ) ){
      case 300:
        {
          char* indexS = strchr( line+currentIndex, 'S' );
          float Spos = atof( indexS + 1);
          //         Serial.println("ok");
          if (Spos == 30) {
            penDown();
          }
          if (Spos == 50) {
            penUp();
          }
          break;
        }
      case 114:                                // M114 - Repport position
        Serial.print( "Absolute position : X = " );
        Serial.print( actuatorPos.x );
        Serial.print( "  -  Y = " );
        Serial.println( actuatorPos.y );
        break;
      default:
        Serial.print( "Command not recognized : M");
        Serial.println( buffer );
      }
    }
  }
}
/*********************************
 * Draw a line from (x0;y0) to (x1;y1).
 * int (x1;y1) : Starting coordinates
 * int (x2;y2) : Ending coordinates
 **********************************/
void drawLine(float x1, float y1) {
  if (verbose)
  {
    Serial.print("fx1, fy1: ");
    Serial.print(x1);
    Serial.print(",");
    Serial.print(y1);
    Serial.println("");
  }  
  //  Bring instructions within limits
  if (x1 >= Xmax) {
    x1 = Xmax;
  }
  if (x1 <= Xmin) {
    x1 = Xmin;
  }
  if (y1 >= Ymax) {
    y1 = Ymax;
  }
  if (y1 <= Ymin) {
    y1 = Ymin;
  }
  if (verbose)
  {
    Serial.print("Xpos, Ypos: ");
    Serial.print(Xpos);
    Serial.print(",");
    Serial.print(Ypos);
    Serial.println("");
  }
  if (verbose)
  {
    Serial.print("x1, y1: ");
    Serial.print(x1);
    Serial.print(",");
    Serial.print(y1);
    Serial.println("");
  }
  //  Convert coordinates to steps
  x1 = (int)(x1*StepsPerMillimeterX);
  y1 = (int)(y1*StepsPerMillimeterY);
  float x0 = Xpos;
  float y0 = Ypos;
  //  Let's find out the change for the coordinates
  long dx = abs(x1-x0);
  long dy = abs(y1-y0);
  int sx = x0<x1 ? StepInc : -StepInc;
  int sy = y0<y1 ? StepInc : -StepInc;
  long i;
  long over = 0;
  if (dx > dy) {
    for (i=0; i<dx; ++i) {
      myStepperX.onestep(sx,STEP);
      over+=dy;
      if (over>=dx) {
        over-=dx;
        myStepperY.onestep(sy,STEP);
      }
    delay(StepDelay);
    }
  }
  else {
    for (i=0; i<dy; ++i) {
      myStepperY.onestep(sy,STEP);
      over+=dx;
      if (over>=dy) {
        over-=dy;
        myStepperX.onestep(sx,STEP);
      }
      delay(StepDelay);
    }  
  }
  if (verbose)
  {
    Serial.print("dx, dy:");
    Serial.print(dx);
    Serial.print(",");
    Serial.print(dy);
    Serial.println("");
  }
  if (verbose)
  {
    Serial.print("Going to (");
    Serial.print(x0);
    Serial.print(",");
    Serial.print(y0);
    Serial.println(")");
  }
  //  Delay before any next lines are submitted
  delay(LineDelay);
  //  Update the positions
  Xpos = x1;
  Ypos = y1;
}

//  Raises pen
void penUp() {
  penServo.write(penZUp);
  delay(penDelay);
  Zpos=Zmax;
  digitalWrite(15, LOW);
    digitalWrite(16, HIGH);
  if (verbose) {
    Serial.println("Pen up!");
 
  }
}
//  Lowers pen
void penDown() {
  penServo.write(penZDown);
  delay(penDelay);
  Zpos=Zmin;
  digitalWrite(15, HIGH);
    digitalWrite(16, LOW);
  if (verbose) {
    Serial.println("Pen down.");
  }
}


.............................................................................................................................






Tuesday 27 February 2018

how To download Arduino Uno Software under Windows

Installing the Arduino Uno Software under Windows


Steps to install Arduino Software (IDE) on Windows 10.fist Go to https://www.arduino.cc

Step1




Step 2





Step 3





Step 4





Step 5





Step 6



step 7






Step 8





Step 9




Step 10





Step 11





Step 12




Step 13




Monday 26 February 2018

Arduino Uno light dependent resistor ( LDR) Contolled LEDS

ARDUINO - LDR WITH LED





Hardware Required

  1. Arduino Uno
  2. LED
  3. LDR (photoresistor)
  4. 220 and 10k ohm resistors
  5. Wires
  6. Breadboard

The lights are Blink sketch allowed us to create a number of LED animations/transitions. But it is only a matter of time before you opt for something more interactive. In this tutorial, we will make use of a photo resistor or light dependent resistor ( LDR) to create an exciting LED display.





Photo resistors are variable resistors which change resistance depending on the amount of light hitting the sensor. When you move your hand closer to the sensor, you tend to block an increasing amount of light, which increases the resistance of the photo resistor. As you move your hand away, the amount of light hitting the surface of the photo resistor increases, thus decreasing the resistance.

The change in the resistance of the LDR, will affect the voltage being read at one of the Arduino's Analog Input pins (A0). As resistance increases, the voltage drops.

V = IR

V = Voltage, I = Current, R = Resistance
The voltage reading will be used to select which LED to turn on





We now have the power to control which LED we want to light up. This would look very nice with different coloured LEDs, but unfortunately I am stuck with the Yellow and Red ones from the Sparkfun Inventor's Kit.


source code :


//Define the analog pin the photo resistor is connected to (A0)
int photoRPin = 0;   

void setup() {
    //initialise the LED Pins as OUTPUTS
    for (int i=4; i<14; i++){
      pinMode (i, OUTPUT);
    }
}

void loop(){
    //Turn off all the LEDs before continuing
    for (int i=4; i<14; i++){
      digitalWrite(i, LOW);
    }
    
 /* Read the light level:
     Adjust the analog reading values ranging from 120 to 600
     to span a range of 4 to 13. The analog reading of 120
     is when there is maximum resistance, and the value of 600
     is when there is minimum resistance. These analog readings
     may vary from photo resistor to photo resistor, and therefor
     you may need to adjust these values to suit your particular
     LDR. */
    int photoRead = map(analogRead(photoRPin), 120, 600, 4, 13);
    
    /* Make sure the value of photoRead does not go beyond the values
      of 4 and 13 */
    int ledPin = constrain(photoRead, 4, 13);
    
    /* Turn the LED on for a fraction of a second */
    digitalWrite(ledPin, HIGH);
    delay(10);
    digitalWrite(ledPin, LOW);
}
    

Thursday 22 February 2018

Esay To Learn Basic OF MIT App Inventor Arduino

 Creating Andriod 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 Technolgy




1. App Inventor: How to Make an Android App - The Basics

 In this tutorial, I show you the basic concepts of Google App Inventor. Keep watching this series to learn many advanced features of the software. Remember, the things I go over in this video are essential to learn before building up your knowledge.



2. Getting Started with Arduino and Android 

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




 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

example code to Arduino 

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

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


3.Multi Servo Motor Control with Arduino and Android app


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


Need for Components
- Arduino Board
- HC-06 / 05 Bluetooth Module
- Servo Motor x4
- Wires and Breadboard
- Battery
- Android Device




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

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



- MIT App Inventor site to create an application.
http://appinventor.mit.edu/explore/



4.Buetooth based stepper motor controller by Arduino :

The Stepper motor used here is a rusty old EPOCH (5 wires) stepper motor, which is a unipolar stepper.

'

Requiredments :

- Bluetooth Module ( for example : HC05 or HC06 )- Jumper Cables Checkout the video to know how the app control stepper motor



Source 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();
}

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



5.Android Arduino Speech Recognition :

Arduino with voice commands using an Android Mobiles Before we make a voice activated home automatic system




More details Watching this vedio :


Thing that you'll need:
- 5 LED Indicators (the color of your choice)
- Arduino UNO (a clone works fine)
- HC-05 Serial Bluetooth Module
- Solderless Breadboard
- Jumper Cables

Bluetooth voice control for arduino source code


//Voice Activated Arduino (Bluetooth + Android)
//Feel free to modify it but remember to give credit

String voice;
int
led1 = 2, //Connect LED 1 To Pin #2
led2 = 3, //Connect LED 2 To Pin #3
led3 = 4, //Connect LED 3 To Pin #4
led4 = 5, //Connect LED 4 To Pin #5
led5 = 6; //Connect LED 5 To Pin #6
//--------------------------Call A Function-------------------------------//
void allon(){
     digitalWrite(led1, HIGH);
     digitalWrite(led2, HIGH);
     digitalWrite(led3, HIGH);
     digitalWrite(led4, HIGH);
     digitalWrite(led5, HIGH);
}
void alloff(){
     digitalWrite(led1, LOW);
     digitalWrite(led2, LOW);
     digitalWrite(led3, LOW);
     digitalWrite(led4, LOW);
     digitalWrite(led5, LOW);
}
//-----------------------------------------------------------------------//
void setup() {
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
}
//-----------------------------------------------------------------------//
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
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  voice += c; //Shorthand for voice = voice + c
  }
  if (voice.length() > 0) {
    Serial.println(voice);
//-----------------------------------------------------------------------//
  //----------Control Multiple Pins/ LEDs----------//
       if(voice == "*all on") {allon();}  //Turn Off All Pins (Call Function)
  else if(voice == "*all off"){alloff();} //Turn On  All Pins (Call Function)

  //----------Turn On One-By-One----------//
  else if(voice == "*TV on") {digitalWrite(led1, HIGH);}
  else if(voice == "*fan on") {digitalWrite(led2, HIGH);}
  else if(voice == "*computer on") {digitalWrite(led3, HIGH);}
  else if(voice == "*bedroom lights on") {digitalWrite(led4, HIGH);}
  else if(voice == "*bathroom lights on") {digitalWrite(led5, HIGH);}
  //----------Turn Off One-By-One----------//
  else if(voice == "*TV off") {digitalWrite(led1, LOW);}
  else if(voice == "*fan off") {digitalWrite(led2, LOW);}
  else if(voice == "*computer off") {digitalWrite(led3, LOW);}
  else if(voice == "*bedroom lights off") {digitalWrite(led4, LOW);}
  else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);}
//-----------------------------------------------------------------------//
voice="";}} //Reset the variable after initiating


6.How to make an Android phone controlled Arduino Robot


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




Complete  Saw this Toturial vedio :





Android RC control Robot using Arduino :





Sample Source Code Of Arduino Robot Car :

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

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