Project tutorial
SSHS CS 7반 3조 StarPointer

SSHS CS 7반 3조 StarPointer © GPL3+

A device that shows where stars are by pointing with lasers.

  • 1,714 views
  • 0 comments
  • 9 respects

Components and supplies

Necessary tools and machines

3drag
3D Printer (generic)
Lasercutter
Laser cutter (generic)
Hy gluegun
Hot glue gun (generic)

Apps and online services

About this project

천문대에서 간단하게 천체 관측을 할 때, 구름과 도시로부터의 광해로 인해 보이는 별이 많지 않은 경우가 많다. 이럴 경우, 관련 지식이 부족한 사람들의 경우 하늘에 현재 보이는 별이 어떤 별인지, 자신이 찾는 별은 어디쯤에 있는지 헷갈리는 경우가 많다. 이 장치는 이러한 상황을 방지하고, 원하는 별의 고도와 방위각을 실시간으로 계산하여 알려주는 장치이다. 고도와 방위각 두 개의 축으로 이루어진 마운트에 별 지시용 레이저 포인터를 장착하여 별이 있는 위치에 자동으로 레이저를 쏴주므로 더욱 쉽게 별의 위치를 파악할 수 있다.

When you observe stars in the observatory, you cannot see many stars because of clouds or lights of the city. When this happens, people with not enough knowledge about stars doesn't know which is the star they are looking at and where the star they want to observe is. This device prevents this from happening. It shows where the star they want to observe is by pointing with a laser pointer.

이 장치의 장점은 관찰 장소나 시간이 바뀌어도 실시간으로 반영하여 계산할 수 있다는 것이다. GPS 센서를 이용해 현재 표준시각과 위도 및 경도 정보를 받아오고, 자기장 센서를 통해 정북쪽 방향을 보정하면 원하는 별의 적도좌표계 정보를 기반으로 계산을 통해 지평좌표계로 변환한 후 이에 맞게 레이저 포인터를 회전시킨다. 레이저 포인터가 장착된 마운트에는 MPU-6050 자이로 칩이 장착되어 있어 현재 레이저포인터가 가리키는 고도를 실시간으로 확인할 수 있다.

The advantages of this device is that it can calculate the star's place whether the time or place changes. We get the time, longitude, and latitude from the GPS module, and get the north direction with magnetic field sensors. Also, we convert equatorial coordinate system to horizontal coordinate system, and turn the laser pointers using stepping motors. On the mount of the laser pointer, there is a MPU-6050 gyro sensor, allowing us to know the altitude by time.

준비물

  • 아두이노 우노 R3 보드 x1
  • 28BYJ-48 스테퍼 모터 + ULN2003 모터 드라이버 x2
  • GY-521 MPU 6050 자이로 센서 x1
  • GY-NEO6MV2 GPS 센서 x1
  • 아크릴 판 (레이저 절단기를 이용해 원형으로 절단) x1
  • 받침대용 나무 판 x1
  • 모터 방위각 마운트(3D 프린터 부품) x1
  • 모터 고도 마운트(3D 프린터 부품) x1
  • 축 마운트(3D 프린터 부품) x2
  • 레이저 포인터 마운트(3D 프린터 부품) x1
  • 3mm 축 회전판 마운트(3D 프린터 부품) x1
  • 3mm 축 x1
  • 3mm/5mm 변환 커플러(3D 프린터 부품) x1
  • M4 볼트 및 너트 다수
  • 점퍼 케이블 다수

Materials needed

  • Arduino Uno R3 board x1
  • 28BYJ-48 stepping motor + ULN2003 Motor driver x2
  • GY-521 MPU 6050 gyro sensor x1
  • GY-NEO6MV2 GPS sensor x1
  • Acrylic board (Cut it into a circle using a laser cutter) x1
  • Wood plate for pedestal x1
  • Mount for stepping motor ,azimuth (3d printed part) x1
  • Mount for stepping motor, altitude (3d printed part) x1
  • Support fixture for the axis (3d printed part) x2
  • Holder for the laser pointer (3d printed part) x1
  • 3mm axis, spindle connecting gear (3d printed part) x1
  • 3mm axis x1
  • 3mm/5mm converting coupler (3d printed part) x1
  • M4 nuts and bolts
  • Jumper cables for arduino

제작 과정

1. 방위각 모터 마운트를 나사못을 이용해 고정용 나무판에 장착한다.

2. 방위각 모터 마운트에 스테퍼 모터를 삽입한다.

3. 회전판 마운트를 볼트와 너트를 이용해 회전판에 연결한다.

4. 아크릴 회전판에 고도 모터 마운트와 축 마운트를 자리에 맞게 설치한다.

5. 고도 조절 모터를 고도 모터 마운트에 볼트와 너트를 이용해 장착한다.

6. 고도 모터 축에 커플러를 연결한 뒤 볼트를 조여 고정한다.

7. 축 마운트 사이에 레이저 포인터 마운트를 넣고 축을 연결한다.

8. 레이저 포인터 마운트의 볼트를 조여 고정하고, 레이저 포인터를 삽입한다.

9. 회전판 부분을 방위각 모터 축에 장착한다.

How to make it

1. Attach the azimuth motor mount to the wooden board using a screw.

2. Attach the stepping motor to the motor mount.

3. Attach the spindle connecting gear to the spindle.

4. Attach the altitude motor mount and support fixture on the acrylic spindle.

5. Fasten the stepping motor to the motor mount using bolts and nuts.

6. Attach the converting coupler to the altitude stepping motor and connect the 3mm axis.

7. Insert the laser pointer holder into the axis.

8. Fix the laser pointer holder using a bolt and insert the laser pointer.

9. Attach the spindle to the azimuth stepping motor.

Explanation of our Star Pointer

Code

star coordinate conversion functionsArduino
Function calc converts Equatorial Coordinate of star N to a Horizontal Coordinate, and prints it in the Serial Monitor. The Code uses star data saved in array stardata, latitude and longitude, localDay and localTime data. ( The program is executed on the (localDay)th day of the year, and the (localTime)th hour of the day.)
float stardata[8][2]={{101.28, -16.71},{78.64, -8.2},{37.95,89.26},{116.33,28.03},{114.83,5.23},{88.79,7.41},{68.98,16.51},{79.17,46}}; // right Ascention, and declination data of Sirius, Rigel, Polaris, Pollux, Procyon,  Betelgeuse, Aldebaran, Capella ( reference : http://www.stellar-database.com/ )
const float pi=3.141592;
float Azimuth, altitude,hourangle,latitude,longitude;
float DtoR(float degree) // Degree to Radian
{
  return degree/360*2*pi;
}
float RtoD(float radian) // Radian to Degree
{
  return radian/2/pi*360;
}
void findAa(double declination) // Finds Azimuth and altitude. NEED HOURANGLE RESULT -> findHourangle()
{
  Azimuth=RtoD( atan(  sin( DtoR(hourangle) ) / ( cos( DtoR(hourangle) )* sin( DtoR(latitude) ) - tan( DtoR(declination) ) * cos( DtoR(latitude) ) ) ) );//https://en.wikipedia.org/wiki/Celestial_coordinate_system
  altitude=RtoD( asin( sin( DtoR(latitude) ) * sin( DtoR(declination) ) + cos( DtoR(latitude) ) * cos( DtoR(declination) ) * cos( DtoR(hourangle) ) ) );
}
void findHourangle(double rightAscention,int localDay, int localTime) //https://archive.org/stream/CalculationOfLocalSiderealTime/Calculation-of-Local-Sidereal-Time_djvu.txt
{
    hourangle = (localDay*0.0657098)+(localTime*1.002737)+6.1265-(longitude-136)/15;               ///longitude!!!!
    if(hourangle<0)
      hourangle+=24;
    else if(hourangle>=24)
      hourangle-=24;
      hourangle=hourangle/24*360;
      hourangle-=rightAscention;
      if(hourangle<0)
        hourangle+=360;
}
void calc(int N)
{
  findHourangle(stardata[N-1][0],360,0);
  findAa(stardata[N-1][1]);
  printf("%f %f",Azimuth,altitude);
}
Code for controlling stepping motor 28BYJ-48Arduino
Code for using the stepping motor. way 1 is clockwise and way 2 is counterclockwise
#define pin1 2
#define pin2 3
#define pin3 4
#define pin4 5
void setup() {
  Serial.begin(115200);
  pinMode(pin1, OUTPUT);
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
  pinMode(pin4, OUTPUT);
}
void turnStepper(float angle,int way){
 float steps=(angle/360)*(2048);
 int countstep=0;
 int delaytime=5000;
 if(way==1){
 while(countstep<steps){
 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 }
 }
 else if(way==-1){
 while(countstep<steps){
 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);
 }
 }
 }

void loop() {
 turnStepper(60.0,1);
 delay(1000);
}
Total codeArduino
This is the total code we used in the star pointer
#define pin1 2
#define pin2 3
#define pin3 4
#define pin4 5
#define pin5 8
#define pin6 9
#define pin7 10
#define pin8 11
#include <Wire.h>
#define mpu_add 0x68

double current_angle_x;
double current_angle_y;
 
double ac_x;
double ac_y;
double ac_z;
double gy_x;
double gy_y;
double gy_z;
double deg_x;
double deg_y;
 
double dgy_x;
double dgy_y;
float stardata[8][2]={{101.28, -16.71},{78.64, -8.2},{37.95,89.26},{116.33,28.03},{114.83,5.23},{88.79,7.41},{68.98,16.51},{79.17,46}};
const float pi=3.141592;
float Azimuth, altitude,hourangle,latitude=35,longitude=136;
int starNo;
float DtoR(float degree) // Degree to Radian
{
  return degree/360*2*pi;
}
float RtoD(float radian) // Radian to Degree
{
  return radian/2/pi*360;
}
void findAa(double declination) // Finds Azimuth and altitude. NEED HOURANGLE RESULT -> findHourangle()
{
  Azimuth=RtoD( atan(  sin( DtoR(hourangle) ) / ( cos( DtoR(hourangle) )* sin( DtoR(latitude) ) - tan( DtoR(declination) ) * cos( DtoR(latitude) ) ) ) );//https://en.wikipedia.org/wiki/Celestial_coordinate_system
  altitude=RtoD( asin( sin( DtoR(latitude) ) * sin( DtoR(declination) ) + cos( DtoR(latitude) ) * cos( DtoR(declination) ) * cos( DtoR(hourangle) ) ) );
}
void findHourangle(double rightAscention,int localDay, int localTime) //https://archive.org/stream/CalculationOfLocalSiderealTime/Calculation-of-Local-Sidereal-Time_djvu.txt
{
    hourangle = (localDay*0.0657098)+(localTime*1.002737)+6.1265-(longitude-136)/15;
    if(hourangle<0)
      hourangle+=24;
    else if(hourangle>=24)
      hourangle-=24;
      hourangle=hourangle/24*360;
      hourangle-=rightAscention;
      if(hourangle<0)
        hourangle+=360;
}
void calc(int N) 
{
  findHourangle(stardata[N-1][0],340,20);
  findAa(stardata[N-1][1]);
}
void inputstarNo()
{
  Serial.println("Hello. What star should I point?");
  Serial.println("1.Sirius 2.Rigel 3.Polaris 4.Pollux");
  Serial.println("5.Procyon 6.Betelgeuse 7.Aldebaran 8.Capella");
  while(1)
  {
    if(Serial.available())
    {
      starNo = Serial.parseInt();
      if(starNo>=1&&starNo<=8)
        break;
      Serial.println("Invalid Input!!");
    }
  }
  Serial.print("Finding ");
  Serial.print(starNo);
  Serial.println("...");
}
void turnStepper1(float angle,int way){
 float steps=(angle/360)*(2048);
 int countstep=0;
 int delaytime=5000;
 if(way==1){
 while(countstep<steps){
 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 }
 }
 else if(way==-1){
 while(countstep<steps){
 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);
 }
 }
 }
 void turnStepper2(float angle,int way){
 float steps=(angle/360)*(2048);
 int countstep=0;
 int delaytime=5000;
 if(way==1){
 while(countstep<steps){
 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 }
 }
 else if(way==-1){
 while(countstep<steps){
 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);
 }
 }
 }

void getaccdata() {
  Wire.beginTransmission(mpu_add) ; //get acc data
  Wire.write(0x3B) ;
  Wire.endTransmission(false) ;
  Wire.requestFrom(mpu_add, 6, true) ;
  ac_x = Wire.read() << 8 | Wire.read() ;
  ac_y = Wire.read() << 8 | Wire.read() ;
  ac_z = Wire.read() << 8 | Wire.read() ;
}
 
void getgyrdata() {
  Wire.beginTransmission(mpu_add) ; //get gyro data
  Wire.write(0x43) ;
  Wire.endTransmission(false) ;
  Wire.requestFrom(mpu_add, 6, true) ;
  gy_x = Wire.read() << 8 | Wire.read() ;
  gy_y = Wire.read() << 8 | Wire.read() ;
  gy_z = Wire.read() << 8 | Wire.read() ;
}
 
void curang() {
  deg_x = atan2(ac_x, ac_z) * 180 / PI ;  //rad to deg
  deg_y = atan2(ac_y, ac_z)*180/PI;
  dgy_x = gy_x / 131. ; 
  dgy_y = gy_y / 131. ; 
  current_angle_x = (0.95 * (current_angle_x + (dgy_x * 0.001))) + (0.05 * deg_x) ;
  current_angle_y = (0.95 * (current_angle_y + (dgy_y * 0.001))) + (0.05 * deg_y) ;
}

void MPUreceive(){
  int a=0;
  while(a++<160)
  {
  getaccdata();
  getgyrdata();
  
  curang();
  Serial.println(current_angle_y);
  }
}
void resetaltitude(){
  MPUreceive();
  if(current_angle_y>0)
    turnStepper1(current_angle_y,1);
  else if(current_angle_y<0)
  turnStepper1(-current_angle_y,-1);
}
void setup() 
{
  Wire.begin();
  Wire.beginTransmission(mpu_add);
  Wire.write(0x6B);
  Wire.write(0);//MPU6050     
  Wire.endTransmission(true);
  Serial.begin(9600);
  pinMode(pin1, OUTPUT);
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
  pinMode(pin4, OUTPUT);
  pinMode(pin5, OUTPUT);
  pinMode(pin6, OUTPUT);
  pinMode(pin7, OUTPUT);
  pinMode(pin8, OUTPUT);
  resetaltitude();
}

void loop() 
{

  inputstarNo();
  calc(starNo);
  Serial.println(altitude);
  Serial.println(Azimuth);
  if(Azimuth<0)
    Azimuth+=360;
  if(altitude<0)
  {
    Serial.println("The star isn't here now!");
  }
  else
  {
    turnStepper1(altitude,1);
    turnStepper2(Azimuth,1);
    delay(10000);
    turnStepper1(altitude,-1);
    turnStepper2(Azimuth,-1);
  }
}
Total codeArduino
This is the total code for the star pointer
#define pin1 2
#define pin2 3
#define pin3 4
#define pin4 5
#define pin5 8
#define pin6 9
#define pin7 10
#define pin8 11
#include <Wire.h>
#define mpu_add 0x68

double current_angle_x;
double current_angle_y;
 
double ac_x;
double ac_y;
double ac_z;
double gy_x;
double gy_y;
double gy_z;
double deg_x;
double deg_y;
 
double dgy_x;
double dgy_y;
float stardata[8][2]={{101.28, -16.71},{78.64, -8.2},{37.95,89.26},{116.33,28.03},{114.83,5.23},{88.79,7.41},{68.98,16.51},{79.17,46}};
const float pi=3.141592;
float Azimuth, altitude,hourangle,latitude=35,longitude=136;
int starNo, localDay, localTime;
float DtoR(float degree) // Degree to Radian
{
  return degree/360*2*pi;
}
float RtoD(float radian) // Radian to Degree
{
  return radian/2/pi*360;
}
void findAa(double declination) // Finds Azimuth and altitude. NEED HOURANGLE RESULT -> findHourangle()
{
  Azimuth=RtoD( atan(  sin( DtoR(hourangle) ) / ( cos( DtoR(hourangle) )* sin( DtoR(latitude) ) - tan( DtoR(declination) ) * cos( DtoR(latitude) ) ) ) );//https://en.wikipedia.org/wiki/Celestial_coordinate_system
  altitude=RtoD( asin( sin( DtoR(latitude) ) * sin( DtoR(declination) ) + cos( DtoR(latitude) ) * cos( DtoR(declination) ) * cos( DtoR(hourangle) ) ) );
}
void findHourangle(double rightAscention) //https://archive.org/stream/CalculationOfLocalSiderealTime/Calculation-of-Local-Sidereal-Time_djvu.txt
{
    hourangle = (localDay*0.0657098)+(localTime*1.002737)+6.1265-(longitude-136)/15;
    if(hourangle<0)
      hourangle+=24;
    else if(hourangle>=24)
      hourangle-=24;
      hourangle=hourangle/24*360;
      hourangle-=rightAscention;
      if(hourangle<0)
        hourangle+=360;
}
void calc(int N) 
{
  findHourangle(stardata[N-1][0]);
  findAa(stardata[N-1][1]);
}
void inputstarNo()
{
  Serial.println("Hello. What star should I point?");
  Serial.println("1.Sirius 2.Rigel 3.Polaris 4.Pollux");
  Serial.println("5.Procyon 6.Betelgeuse 7.Aldebaran 8.Capella");
  while(1)
  {
    if(Serial.available())
    {
      starNo = Serial.parseInt();
      if(starNo>=1&&starNo<=8)
        break;
      Serial.println("Invalid Input!!");
    }
  }
  Serial.print("Finding ");
  Serial.print(starNo);
  Serial.println("...");
}
void turnStepper1(float angle,int way){
 float steps=(angle/360)*(2048);
 int countstep=0;
 int delaytime=5000;
 if(way==1){
 while(countstep<steps){
 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 }
 }
 else if(way==-1){
 while(countstep<steps){
 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,HIGH);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,LOW);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,HIGH);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin1,LOW);
 digitalWrite(pin2,LOW);
 digitalWrite(pin3,HIGH);
 digitalWrite(pin4,HIGH);
 countstep++;
 delayMicroseconds(delaytime);
 }
 }
 }
 void turnStepper2(float angle,int way){
 float steps=(angle/360)*(2048);
 int countstep=0;
 int delaytime=5000;
 if(way==1){
 while(countstep<steps){
 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 }
 }
 else if(way==-1){
 while(countstep<steps){
 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,HIGH);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,LOW);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,HIGH);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,LOW);
 countstep++;
 delayMicroseconds(delaytime);

 digitalWrite(pin5,LOW);
 digitalWrite(pin6,LOW);
 digitalWrite(pin7,HIGH);
 digitalWrite(pin8,HIGH);
 countstep++;
 delayMicroseconds(delaytime);
 }
 }
 }

void getaccdata() {
  Wire.beginTransmission(mpu_add) ; //get acc data
  Wire.write(0x3B) ;
  Wire.endTransmission(false) ;
  Wire.requestFrom(mpu_add, 6, true) ;
  ac_x = Wire.read() << 8 | Wire.read() ;
  ac_y = Wire.read() << 8 | Wire.read() ;
  ac_z = Wire.read() << 8 | Wire.read() ;
}
 
void getgyrdata() {
  Wire.beginTransmission(mpu_add) ; //get gyro data
  Wire.write(0x43) ;
  Wire.endTransmission(false) ;
  Wire.requestFrom(mpu_add, 6, true) ;
  gy_x = Wire.read() << 8 | Wire.read() ;
  gy_y = Wire.read() << 8 | Wire.read() ;
  gy_z = Wire.read() << 8 | Wire.read() ;
}
 
void curang() {
  deg_x = atan2(ac_x, ac_z) * 180 / PI ;  //rad to deg
  deg_y = atan2(ac_y, ac_z)*180/PI;
  dgy_x = gy_x / 131. ; 
  dgy_y = gy_y / 131. ; 
  current_angle_x = (0.95 * (current_angle_x + (dgy_x * 0.001))) + (0.05 * deg_x) ;
  current_angle_y = (0.95 * (current_angle_y + (dgy_y * 0.001))) + (0.05 * deg_y) ;
}

void MPUreceive(){
  int a=0;
  while(a++<160)
  {
  getaccdata();
  getgyrdata();
  
  curang();
  Serial.println(current_angle_y);
  }
}
void resetaltitude(){
  MPUreceive();
  if(current_angle_y>0)
    turnStepper1(current_angle_y,1);
  else if(current_angle_y<0)
  turnStepper1(-current_angle_y,-1);
}
void setup() 
{
  Wire.begin();
  Wire.beginTransmission(mpu_add);
  Wire.write(0x6B);
  Wire.write(0);//MPU6050     
  Wire.endTransmission(true);
  Serial.begin(9600);
  pinMode(pin1, OUTPUT);
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
  pinMode(pin4, OUTPUT);
  pinMode(pin5, OUTPUT);
  pinMode(pin6, OUTPUT);
  pinMode(pin7, OUTPUT);
  pinMode(pin8, OUTPUT);
  resetaltitude();
  Serial.println("What day, what time is it?");
  while(1)
  {
    if(Serial.available())
    {
      localDay = Serial.parseInt();
      if(localDay>=1&&localDay<=366)
        break;
      Serial.println("Invalid Input!!");
    }
  }
  while(1)
  {
    if(Serial.available())
    {
      localTime = Serial.parseInt();
      if(localTime>=1&&localTime<=24)
        break;
      Serial.println("Invalid Input!!");
    }
  }
}

void loop() 
{

  inputstarNo();
  calc(starNo);
  Serial.println(altitude);
  Serial.println(Azimuth);
  if(Azimuth<0)
    Azimuth+=360;
  if(altitude<0)
  {
    Serial.println("The star isn't here now!");
  }
  else
  {
    turnStepper1(altitude,1);
    turnStepper2(Azimuth,1);
    delay(10000);
    turnStepper1(altitude,-1);
    turnStepper2(Azimuth,-1);
  }
}
Code for using MPU-6050Arduino
The code gets the accelerating data and the angle data from MPU_6050.
#include <Wire.h>
#define mpu_add 0x68

double current_angle_x;
double current_angle_y;
 
double ac_x;
double ac_y;
double ac_z;
double gy_x;
double gy_y;
double gy_z;
double deg_x;
double deg_y;
 
double dgy_x;
double dgy_y;
 
void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  Wire.beginTransmission(mpu_add);
  Wire.write(0x6B);
  Wire.write(0);//MPU6050     
  Wire.endTransmission(true);
    Serial.begin(9600);
}
 
void loop() {
  // put your main code here, to run repeatedly:
 
  getaccdata();
  getgyrdata();
  
  curang();

  Serial.println((unsigned long)millis());
  Serial.println();
  Serial.println(current_angle_x);
  Serial.println(current_angle_y);
}
 
void getaccdata() {
  Wire.beginTransmission(mpu_add) ; //get acc data
  Wire.write(0x3B) ;
  Wire.endTransmission(false) ;
  Wire.requestFrom(mpu_add, 6, true) ;
  ac_x = Wire.read() << 8 | Wire.read() ;
  ac_y = Wire.read() << 8 | Wire.read() ;
  ac_z = Wire.read() << 8 | Wire.read() ;
}
 
void getgyrdata() {
  Wire.beginTransmission(mpu_add) ; //get gyro data
  Wire.write(0x43) ;
  Wire.endTransmission(false) ;
  Wire.requestFrom(mpu_add, 6, true) ;
  gy_x = Wire.read() << 8 | Wire.read() ;
  gy_y = Wire.read() << 8 | Wire.read() ;
  gy_z = Wire.read() << 8 | Wire.read() ;
}
 
void curang() {
  deg_x = atan2(ac_x, ac_z) * 180 / PI ;  //rad to deg
  deg_y = atan2(ac_y, ac_z)*180/PI;
  dgy_x = gy_x / 131. ; 
  dgy_y = gy_y / 131. ; 
  current_angle_x = (0.95 * (current_angle_x + (dgy_x * 0.001))) + (0.05 * deg_x) ;
  current_angle_y = (0.95 * (current_angle_y + (dgy_y * 0.001))) + (0.05 * deg_y) ;
}
 

Custom parts and enclosures

Holder for stepper motor(28BYJ-48)
Holder for 28BYJ-48 used as the azimuth axis.
Gear used to connect the stepper to the acrylic circular plane
Stepper holder for altitude
28BYJ-48 holder for altitude changes
MPU-6050 case(base)
The case for MPU-6050(base part)
You need to print this as 1000%
MPU-6050 case(Lid)
Case for MPU-6050(lid)
You need to print this as 1000%
Case for laser pointer
Holder for laser pointer which can connect with a 3mm axis

Schematics

Circuit Design
Arduino Uno R3 board + MPU 6050 (GY-521) gyro sensor+ GY-NEO6MV2 GPS sensor
  41atcm9imf

Comments

Similar projects you might like

Joy Robot (Robô Da Alegria)

Project tutorial by Igor Fonseca Albuquerque

  • 2,320 views
  • 1 comment
  • 23 respects

Otto DIY+ Arduino Bluetooth Robot Easy to 3D Print

Project tutorial by Team Otto builders

  • 48,196 views
  • 117 comments
  • 162 respects

Industrial Line Follower for Supplying Materials

Project tutorial by Nikodem Bartnik

  • 2,980 views
  • 1 comment
  • 8 respects

3D-Printed RGB Wallet

Project tutorial by Alex Wulff

  • 1,665 views
  • 0 comments
  • 8 respects

Binary Wristwatch

Project showcase by thallia

  • 979 views
  • 0 comments
  • 9 respects

Raspberry Pi - Powered Candy Dispenser

Project tutorial by Arduino “having11” Guy

  • 5,283 views
  • 1 comment
  • 12 respects
Add projectSign up / Login