Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
tehcwan_canel
Published © LGPL

Arm Robot + Mobile App

Control arm robot by smartphone via bluetooth HC-05

IntermediateFull instructions provided4,178
Arm Robot + Mobile App

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×4
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Arm robot wood kit
×1
Mobile Phone
×1

Software apps and online services

Android Studio
Android Studio

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

Drawing

Picture doesn't same with actual schematic and program, Sorry i dont have any schematic drawing so i draw online

Code

Arduino code

Arduino
String inString = "";    // string to hold input

#include <Servo.h> 
// Declare the Servo pin 
int servoPin = 8 , servoPin2 = 9,servoPin3 = 10, servoPin4 = 11 ; 

Servo Servo1, Servo2 , Servo3 , Servo4; 

void setup() {

  Servo1.attach(servoPin); 
  Servo2.attach(servoPin2); 
  Servo3.attach(servoPin3); 
  Servo4.attach(servoPin4); 

  Servo1.write(0);
  Servo2.write(0);
  Servo3.write(0);
  Servo4.write(0);
  
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  /*while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // send an intro:
  Serial.println("\n\nString toInt():");
  Serial.println();

  */
}


void loop() {
  // Read serial input:
  while (Serial.available() > 0) {
    int inChar = Serial.read();
    if (isDigit(inChar)) {
      // convert the incoming byte to a char and add it to the string:
      inString += (char)inChar;
    }

         
    // if you get a newline, print the string, then the string's value:
    if (inChar == '\n') {
      Serial.print("Value:");
      Serial.println(inString.toInt());

      int value = inString.toInt();
      
                      if(value>=0 && value<=90){
                      Serial.println(value); 
                      int servo1_position = map(value, 0, 90, 0, 180);
                      Servo1.write(servo1_position);
                      }
                     if(value>90 && value<=181){
                      Serial.println(value); 
                      int servo2_position = map(value, 91, 181, 0, 180);
                      Servo2.write(servo2_position);
                      }
                
                    if(value>181 && value<=272){
                      Serial.println(value); 
                      int servo3_position = map(value, 182, 272, 0, 180);
                      Servo3.write(servo3_position);
                      }
                
                    if(value>272 && value<=363){
                      Serial.println(value); 
                      int servo4_position = map(value, 273, 363, 0, 180);
                      Servo4.write(servo4_position);
                      }
    
      inString = "";

  
      
      //Serial.print("String: ");
      //Serial.println(inString);
      // clear the string for new input:
     // 
    }
    
  }
}

Credits

tehcwan_canel

tehcwan_canel

0 projects • 1 follower

Comments