Tuesday, May 26, 2015

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:







Wednesday, May 13, 2015

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.