Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Arduino/9. Automatic Garage Door .docx
Binary file not shown.
53 changes: 53 additions & 0 deletions Arduino/Automatic Garage Door Code
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

/*
Stepper Motor Control -Automatic Garage_Door

This program drives a unipolar or bipolar stepper motor.
It will close the door for '1' input and open the door for '0' input.
*/

#include <Stepper.h>
#include <SoftwareSerial.h>


SoftwareSerial BT(0,1);
// creates a "virtual" serial port/UART
// connect BT module TX to D0
// connect BT module RX to D1
// connect BT Vcc to 5V, GND to GND
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins:
Stepper myStepper(stepsPerRevolution, 5,6,9,10);

void setup() {
BT.begin(9600); // set the data rate for the SoftwareSerial port
myStepper.setSpeed(60); // set the speed at 60 rpm
Serial.begin(9600); // initialize the serial port
}
char a; // stores incoming character from other device

void loop() {
if(BT.available())
{
// if text arrived in from BT serial...
a=(BT.read());
if(a=='1'){
Serial.write(a);
//clockwise direction
for(int i=0;i<=8;i++)//{
myStepper.step(stepsPerRevolution);
//delay(20);}
BT.write('1');
}
else if(a=='0'){
Serial.write(a);
// anti-clockwise direction
for(int i=0;i<=8;i++)//{
myStepper.step(-stepsPerRevolution);
//delay(20);}
BT.write('0');
}
}
}
Binary file not shown.
Binary file added Arduino/garage_door_updated (Labelled).fzz
Binary file not shown.
1 change: 1 addition & 0 deletions Self Stabilization Platform
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the complete
58 changes: 58 additions & 0 deletions code of Self Stabalization
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <Wire.h>

#include <MPU6050.h>

#include <Servo.h>

Servo sg90;

int servo_pin = 2;

MPU6050 sensor ;

int16_t ax, ay, az ;

int16_t gx, gy, gz ;

void setup ( )

{

sg90.attach ( servo_pin );

Wire.begin ( );

Serial.begin (9600);

Serial.println ( "Initializing the sensor" );

sensor.initialize ( );

Serial.println (sensor.testConnection ( ) ? "Successfully Connected" : "Connection failed");

delay (1000);

Serial.println ( "Taking Values from the sensor" );

delay (1000);

}




void loop ( )

{

sensor.getMotion6 (&ax, &ay, &az, &gx, &gy, &gz);

ax = map (ax, -17000, 17000, 0, 180) ;

Serial.println (ax);

sg90.write (ax);

delay (200);

}