KARTHIKEYAN SUNDARARAMAN
Created August 23, 2019 © GPL3+

AI Driven PET Monitor

Smart way to track your PET's activity away from home and be ensured of its safety.

IntermediateFull instructions provided52
AI Driven PET Monitor

Things used in this project

Hardware components

SmartEdge Agile Brainium
Avnet SmartEdge Agile Brainium
×1
Android device
Android device
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×4
PCA9685 16 Channe 12Bit PWM Servo Motor Driver
×1
Arduino UNO
Arduino UNO
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Rechargeable Battery, Lithium Ion
Rechargeable Battery, Lithium Ion
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Avnet Brainium Portal
MIT App Inventor 2
MIT App Inventor 2
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Robot-Appu Hardware Behind

Robot-Appu Schematics

Wiring details

Code

Robot-Appu Code Behind

Arduino
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <SoftwareSerial.h>
#define ioPin 4

String state = "";

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

#define SERVOMIN  300 // minimum pulse length count for servo fixed for stable leg movement
#define SERVOMAX  400 // maximum pulse length count for servo fixed for stable leg movement

//For Bluetooth module 
SoftwareSerial bt(2,3); /*(Rx,Tx) */  


void setup() {
  pinMode(ioPin, OUTPUT);
  digitalWrite(ioPin, HIGH); // Kept HIGH to powerup bluetooth module
  bt.begin(9600);  // Default communication rate of the Bluetooth module
  Serial.begin(9600);
  pwm.begin(); // for handling servos
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  delay(10);
}

// An extract from Adafruit PWM Servo Driver Library
void setServoPulse(uint8_t n, double pulse) {
  double pulselength;
  pulselength = 1000000;   // 1,000,000 us per second
  pulselength /= 60;   // 60 Hz
  Serial.print(pulselength); Serial.println(" us per period"); 
  pulselength /= 4096;  // 12 bits of resolution
  Serial.print(pulselength); Serial.println(" us per bit"); 
  pulse *= 1000000;  // convert to us
  pulse /= pulselength;
  Serial.println(pulse);
  pwm.setPWM(n, 0, pulse);

}



void loop() {

  if(bt.available() > 0){ // Checks whether data is comming from the serial port
    state = bt.readString();
    Serial.println(state);
   
  }
  
  if (state == "0") {
    Serial.println("Position - STAND");;
   
    //// STANDING POSITION - Checked & Tested Servo Positions for Robot-Appu 
    //Servo front - right
    pwm.setPWM(0, 0, 250);

    //Servo front - left   
    pwm.setPWM(1, 0, 400);

   //Servo Rear - left   
    pwm.setPWM(3, 0, 350);
  
   //Servo Rear - right   
   pwm.setPWM(2, 0, 350);
    delay(500);

   state = "";
  }
 
  else if (state == "1") {
    Serial.println("Position - SIT");;
    state = "";
  
    //// SITTING POSITION - Checked & Tested Servo Positions for Robot-Appu
    //servo front - right
     pwm.setPWM(0, 0, 210);

    //servo front - left   
     pwm.setPWM(1, 0, 400);

    //servo Rear - left   
    pwm.setPWM(3, 0, 280);

    //servo Rear - right   
    pwm.setPWM(2, 0,430);
   
  delay(500);

  } 

 else if (state == "2") {
  Serial.println("WALK");
     
    //// ACTION WALKING (FRONT TO BACK) - Checked & Tested Servo Positions for Robot-Appu
    //Servo front - right
    for (uint16_t pulselen = 200; pulselen < 300; pulselen++) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(0, 0, pulselen);
         
    }
    
    //Servo front - left 
    for (uint16_t pulselen = 350; pulselen < 450; pulselen++) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(1, 0, pulselen);
         
    }
    
    
    //Servo Rear - left
    for (uint16_t pulselen = 400; pulselen > 300; pulselen--) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(3, 0, pulselen);
         
    }
    
    //Servo Rear - right  
    for (uint16_t pulselen = 400; pulselen > 300; pulselen--) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(2, 0, pulselen);
         
    }
    
    delay(300);
    
    
    //// ACTION WALKING (BACK TO FRONT) - Checked & Tested Servo Positions for Robot-Appu
    
    //Servo front - right
    for (uint16_t pulselen = 300; pulselen > 150; pulselen--) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(0, 0, pulselen);
         
    }
    
    //Servo front - left 
    for (uint16_t pulselen = 450; pulselen > 350; pulselen--) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(1, 0, pulselen);
         
    } 
    
    
    //Servo Rear - left
    for (uint16_t pulselen = 300; pulselen < 400; pulselen++) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(3, 0, pulselen);
         
    }
    
    //Servo Rear - right  
    for (uint16_t pulselen = 300; pulselen < 400; pulselen++) {
       //pwm.setPWM(servonum, 0, pulselen);
       pwm.setPWM(2, 0, pulselen);
         
    }
    
    delay(300);

  }
}

Robot-Appu Android App

Scratch
Developed using MIT App Inventor
No preview (download only).

Credits

KARTHIKEYAN SUNDARARAMAN

KARTHIKEYAN SUNDARARAMAN

2 projects • 2 followers
An Engineer by profession, an electronic Hobbyist interested in learning, sharing and appreciate recent technologies

Comments