0% found this document useful (0 votes)
9 views1 page

Ardinyo

The document is an Arduino sketch that controls a stepper motor using an infrared remote. It allows the motor to rotate clockwise when the '5' button is pressed on the remote, with a toggle feature to start and stop the motor. The code also includes LED feedback and serial output for debugging purposes.

Uploaded by

furkanmert0343
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Ardinyo

The document is an Arduino sketch that controls a stepper motor using an infrared remote. It allows the motor to rotate clockwise when the '5' button is pressed on the remote, with a toggle feature to start and stop the motor. The code also includes LED feedback and serial output for debugging purposes.

Uploaded by

furkanmert0343
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <Stepper.

h>
#include <IRremote.hpp>

const int IR_RECEIVE_PIN = 7;


const int redPin = 10;
const int adim = 64;
const int hiz = 600;
const int STEP_DELAY = 10; // Motoru döndürürken bekleme süresi

Stepper step_motor_git = Stepper(adim, 2, 4, 3, 5);

bool motorContinuously = false;

void setup() {
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
pinMode(redPin, OUTPUT);
Serial.begin(9600);
step_motor_git.setSpeed(hiz);
}

void loop() {
if (IrReceiver.decode()) {
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
IrReceiver.printIRResultShort(&Serial);

switch (IrReceiver.decodedIRData.decodedRawData) {
case 0xE31CFF00: // Keypad button "5"
Serial.println("5");
Serial.println("Saat Yönünde");

// Toggle the motorContinuously flag


motorContinuously = !motorContinuously;

if (motorContinuously) {
digitalWrite(redPin, HIGH);
while (motorContinuously) {
step_motor_git.step(1); // Motoru saat yönünde döndür
delay(STEP_DELAY); // Bekleme süresi, motor hızını kontrol eder
if (IrReceiver.decode()) { // Kontrol için yeni bir IR sinyali al
if (IrReceiver.decodedIRData.decodedRawData != 0xE31CFF00) {
motorContinuously = false; // Motoru durdur
}
IrReceiver.resume(); // Enable receiving of the next value
}
}
digitalWrite(redPin, LOW);
} else {
digitalWrite(redPin, LOW);
}
break;

default:
break;
}
IrReceiver.resume(); // Enable receiving of the next value
}
}

You might also like