Saturday 16 June 2018

Arduino Tutorial - stepper motor with bluetooth

1





This Blogger is the written version of my "Arduino : How To Control Stepper Motor via Bluetooth (with Smartphone)"
In this project we will control a Stepper motor with a smartphone via bluetooth. My YouTube Channel First, you should see the following Instructable: How to Control a Stepper Motor With L293D Motor Driver

 Hardware Required

- Bluetooth Module ( for example : HC05 or HC06 ) 
- Jumper Cables

Circuit & Connections

Bluetooth Modul VCC to Arduino 5V
(at the same time if you want, you can use 3V3)
Bluetooth Modul GND to Arduino GND
Bluetooth Modul RX to Arduino TX
Bluetooth Modul TX to Arduino RX

Create Application



Get the Application (Google Drive)

 Get Code :-

int step_pin_1 = 8; 
int step_pin_2 = 9; 
int step_pin_3 = 10; 
int step_pin_4 = 11;

float delay_time;
int value_bluetooth = 0;

 
String readString;

void setup()
{
Serial.begin(9600);
}

void loop() 
{
   
   while (Serial.available()){
    char c= Serial.read();
    readString+=c;
  }

  if(readString.length() >0) {
   
    value_bluetooth =readString.toInt();

   if (value_bluetooth >  0   ){
      delay_time = 15;  
    }
    else
    {
      delay_time=0;
      }

Serial.println(value_bluetooth);

 
digitalWrite(8, HIGH); digitalWrite(step_pin_2, HIGH); digitalWrite(step_pin_3, LOW); digitalWrite(step_pin_4, LOW);   
delay(delay_time);


digitalWrite(step_pin_1, LOW); digitalWrite(step_pin_2, HIGH); digitalWrite(step_pin_3, HIGH); digitalWrite(step_pin_4, LOW);  
delay(delay_time);

digitalWrite(step_pin_1, LOW); digitalWrite(step_pin_2, LOW); digitalWrite(step_pin_3, HIGH); digitalWrite(step_pin_4, HIGH);  
delay(delay_time);
 
digitalWrite(step_pin_1, HIGH); digitalWrite(step_pin_2, LOW); digitalWrite(step_pin_3, LOW); digitalWrite(step_pin_4, HIGH);  
delay(delay_time); 


readString="";

}

}

Author Image

About Tech Hunt
Soratemplates is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design

1 comment: