NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//STEP MOTOR KUTUPHANESI
#include <CustomStepper.h>
#include <TM1637Display.h>


// Motor pin AYARLARI

const int KAT1 = 13;
const int KAT2 = 12;
const int KAT3 = 11;
const int KAT4 = 10;

const int AKAT1 = 6;
const int AKAT2 = 7;
const int AKAT3 = 8;
const int AKAT4 = 9;

const int SENSOR_A1 = 14;
const int SENSOR_A2 = 15;
const int SENSOR_A3 = 16;
const int SENSOR_A4 = 17;

// Module connection pins (Digital Pins)
#define CLK 18
#define DIO 19

// The amount of time (in milliseconds) between tests
#define TEST_DELAY 2000

const uint8_t SEG_DONE[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, // O
SEG_C | SEG_E | SEG_G, // n
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G // E
};

TM1637Display display(CLK, DIO);

CustomStepper stepper1(2, 3, 4, 5, (byte[]) {8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001}, 4075.7728395, 12, CW);



// DEGISKENLER
int SENSORDURUM_A1 = 0;
int SENSORDURUM_A2 = 0;
int SENSORDURUM_A3 = 0;
int SENSORDURUM_A4 = 0;
int KAT_BUTON1 = 0;
int KAT_BUTON2 = 0;
int KAT_BUTON3 = 0;
int KAT_BUTON4 = 0;
int AKAT_BUTON1 = 0;
int AKAT_BUTON2 = 0;
int AKAT_BUTON3 = 0;
int AKAT_BUTON4 = 0;
int KABINYERI = 0;
int MOTOR_SAY = 0;
int MOTOR_SAY1 = 0;
int MOTOR_SAY2 = 0;
int DURUM = 0;
int ADURUM = 0;
int YER1 = 1;
int YER2 = 1;
int HAREKET1 = 0;
int HAREKET2 = 0;
int LIMIT_UST = 11500;
int LIMIT_ORTA = 5750;
int LIMIT_ALT = -11500;
boolean AKTIF = false;

void setup() {
Serial.begin(115200); //
//PIN DURUM AYARLARI

pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);


digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);



pinMode(KAT1, INPUT_PULLUP);
pinMode(KAT2, INPUT_PULLUP);
pinMode(KAT3, INPUT_PULLUP);
pinMode(KAT4, INPUT_PULLUP);
pinMode(AKAT1, INPUT_PULLUP);
pinMode(AKAT2, INPUT_PULLUP);
pinMode(AKAT3, INPUT_PULLUP);
pinMode(AKAT4, INPUT_PULLUP);
pinMode(SENSOR_A1, INPUT_PULLUP);
pinMode(SENSOR_A2, INPUT_PULLUP);
pinMode(SENSOR_A3, INPUT_PULLUP);
pinMode(SENSOR_A4, INPUT_PULLUP);

int k;
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
display.setBrightness(0x0f);

// All segments on



//STEP MOTOR HIZ AYARLARI

//CCW - YUKARI
//CW ASAGI

stepper1.isDone() ;
stepper1.setDirection(CW);
stepper1.rotateDegrees(3000);
stepper1.setRPM(12);
stepper1.setSPR(4075.7728395);

while (DURUM == 0) { // ALT KAT SENSORLERI KABINI GORENE KADAR ASANSORLERI ASAGIYA AL
SENSORDURUM_A1 = digitalRead(SENSOR_A1); // KABIN SENSORUNE BAK

if (SENSORDURUM_A1 == LOW) { // 1. SENSOR DURUMU LOW ISE
stepper1.setDirection(STOP);
MOTOR1_DUR();
} else {
stepper1.run(); //1. MOTOR DUR
}

if (SENSORDURUM_A1 == LOW) { // 1. SENSOR DURUMU LOW ISE VE 2. SENSOR DURUMU LOW ISE DEVAM ET


display.setSegments(0);
display.showNumberDec(1, 0);
break;
}

}


}






void loop() {

// SENSORLERI KONTROL ET



SENSORDURUM_A1 = digitalRead(SENSOR_A1);
SENSORDURUM_A2 = digitalRead(SENSOR_A2);
SENSORDURUM_A3 = digitalRead(SENSOR_A3);
SENSORDURUM_A4 = digitalRead(SENSOR_A4);

Serial.print("sensor = ");
Serial.print(SENSORDURUM_A1);
Serial.print(" - ");
Serial.print(SENSORDURUM_A2);
Serial.print(" - ");
Serial.print(SENSORDURUM_A3);
Serial.print(" - ");
Serial.println(SENSORDURUM_A4);

// ASANOR HIZLARINI ARTTIR

BUTONBAK(); // KAT BUTONLARINA BAK
if ((SENSORDURUM_A4 == LOW) && ( KABINYERI!=4)) {
KABINYERI=4;
display.setSegments(0);
display.showNumberDec(KABINYERI, 0);
}

if ((SENSORDURUM_A3 == LOW)&& ( KABINYERI!=3)) {
KABINYERI=3;
display.setSegments(0);
display.showNumberDec(KABINYERI, 0);
}
if ((SENSORDURUM_A2 == LOW) && ( KABINYERI!=2)) {
KABINYERI=2;
display.setSegments(0);
display.showNumberDec(KABINYERI, 0);
}
if ((SENSORDURUM_A1 == LOW) && ( KABINYERI!=1)) {
KABINYERI=1;
display.setSegments(0);
display.showNumberDec(KABINYERI, 0);
}






if (stepper1.isDone() == true ) { // 1. STEP MOTOR DURDUYSA DURUMLARI SIFIRLA
if (HAREKET1 == 1 ) {
DURUM = 0;
ADURUM = 0;
HAREKET1 = 0;
}
}
if ((DURUM == 4) || (ADURUM == 4)) // 4. KATA CIK
{

if (SENSORDURUM_A4 == LOW) { // 4. KAT SENSORU ALGILARSA DUR
stepper1.setDirection(STOP);
MOTOR1_DUR();
} else {

stepper1.setDirection(CCW);
stepper1.rotateDegrees(2250);
HAREKET1 = 1;
YER1 = 4;
delay(1);
}
}



if ((DURUM == 3) || (ADURUM == 3)) // 3. KATA CIK
{

if (SENSORDURUM_A3 == LOW) { // 3. KAT SENSORU ALGILARSA DUR
stepper1.setDirection(STOP);
MOTOR1_DUR();
} else {

if (YER1 < 3) {
stepper1.setDirection(CCW);
}
if (YER1 == 4) {
stepper1.setDirection(CW);
}
stepper1.rotateDegrees(2250);
HAREKET1 = 1;
YER1 = 3;
delay(1);
}

}



if ((DURUM == 2) || (ADURUM == 2)) // 2. KATA CIK
{

if (SENSORDURUM_A2 == LOW) {// 2. KAT SENSORU ALGILARSA DUR
stepper1.setDirection(STOP);
MOTOR1_DUR();
} else {

if (YER1 == 1) {
stepper1.setDirection(CCW);
}
if (YER1 > 2) {
stepper1.setDirection(CW);
}
stepper1.rotateDegrees(2250);
HAREKET1 = 1;
YER1 = 2;
delay(1);
}
}




if ((DURUM == 1) || (ADURUM == 1))
{

if (SENSORDURUM_A1 == LOW) {// 1. KAT SENSORU ALGILARSA DUR
stepper1.setDirection(STOP);
MOTOR1_DUR();
} else {

stepper1.setDirection(CW);
stepper1.rotateDegrees(2250);
HAREKET1 = 1;
YER1 = 1;
delay(1);
}
}


stepper1.run(); // MOTORU CALISTIR

}

void BUTONBAK() {

// KAT BUTONLARINA BAK
KAT_BUTON1 = digitalRead(KAT1);
KAT_BUTON2 = digitalRead(KAT2);
KAT_BUTON3 = digitalRead(KAT3);
KAT_BUTON4 = digitalRead(KAT4);
AKAT_BUTON1 = digitalRead(AKAT1);
AKAT_BUTON2 = digitalRead(AKAT2);
AKAT_BUTON3 = digitalRead(AKAT3);
AKAT_BUTON4 = digitalRead(AKAT4);



if (KAT_BUTON1 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
DURUM = 1;
}

delay(5);
}

if (KAT_BUTON2 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
DURUM = 2;
}

delay(5);
}

if (KAT_BUTON3 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
DURUM = 3;
}

delay(5);
}

if (KAT_BUTON4 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
DURUM = 4;
}

delay(5);
}

if (AKAT_BUTON1 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
ADURUM = 1;
}

delay(5);
}

if (AKAT_BUTON2 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
ADURUM = 2;
}

delay(5);
}

if (AKAT_BUTON3 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
ADURUM = 3;
}

delay(5);
}

if (AKAT_BUTON4 == LOW) { // 1. KAT CAGIRMA BUTONUNA BASILDIMI
if ( HAREKET1 == 0 )
{
ADURUM = 4;
}

delay(5);
}



}


void MOTOR1_DUR() { // 1. MOTORU DURDUR
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
ADURUM = 0;
DURUM = 0;
HAREKET1 = 0;


}

     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.