arduino controlled motor and servo in tamil



if you want my app dowload here:

https://docs.google.com/uc?export=download&id=1hZIQLwD-Ou2L5EhuSKH4Tmn6ECjB-kJ_


codings

#include <SoftwareSerial.h> 
#include <Servo.h>

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

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
int motorpas = 5; //connect passitive pin of motor in 5
int motorneg = 6; //connect negative pin of motor in 6
int servoPin = 9; //connect servo signal pin in 9
int level = 0;
void setup() {
 Serial.begin(9600);
 bluetooth.begin(9600);
 pinMode(motorpas,OUTPUT);
 pinMode(motorneg,OUTPUT);
 servo.attach(servoPin);
}


void loop() {
  if(bluetooth.available()>0)
  {
    unsigned int cmt;
    cmt = bluetooth.read();
    Serial.write(cmt);
    Serial.println();
    if(cmt == 'a')
    {
      servo.write(0);
    }
    else if(cmt == 'b')
    {
      servo.write(45);
    }
    else if(cmt == 'c')
    {
      servo.write(90);
    }
    else if(cmt == 'd')
    {
      servo.write(135);
    }
    else if(cmt == 'e')
    {
      servo.write(180);
    }
    else if(cmt == 'f')
    {
      digitalWrite(motorpas,HIGH);
      digitalWrite(motorneg,LOW);
      Serial.println("FORWORD");
    }
    else if(cmt == 'r')
    {
      digitalWrite(motorpas,LOW);
      digitalWrite(motorneg,HIGH);
      Serial.println("REVERSE");
    }    
    else if(cmt == 'l')
    {
      level = level - 20;
      analogWrite(motorpas,level);
      digitalWrite(motorneg,LOW);
      Serial.println(level);
    }  
    else if(cmt == 'h')
    {
      level = level + 20;
      analogWrite(motorpas,level);
      digitalWrite(motorneg,LOW);
      Serial.println(level);
    }  
     
  }
}
************------------------********************----------***************

Comments

  1. bro where is your bluetooth code how we learn ???????

    ReplyDelete

Post a Comment

Popular posts from this blog

using millis() in ultrasonic sensor program in tamil

CHATBOT programming tutorial in tamil

RFID attendance system review in tamil