/*
Potansiyometre ile makinenin step motorun hızını ayarlar.
Step motor Sürücüsü için gerekli frekansı üretir
*/
#define PulsPin 3
#define SW1Pin 5
#define SW2Pin 6
#define podPin A0
#define DirOut 13
int sure;
int podDeger;
void setup() {
pinMode(PulsPin, OUTPUT);
pinMode(DirOut, OUTPUT);
pinMode(podPin, INPUT);
pinMode(SW1Pin, INPUT);
pinMode(SW2Pin, INPUT);
sure = 50;
podDeger = 0;
TCCR2B = TCCR2B & B11111000 | B00000001; // for PWM frequency of 31372.55 Hz
}
void loop() {
if (digitalRead(SW1Pin) == HIGH) {
digitalWrite(DirOut, LOW);
}
if (digitalRead(SW2Pin) == HIGH) {
digitalWrite(DirOut, HIGH);
}
podDeger = analogRead(podPin);
sure = map(podDeger, 0, 1023, 5, 0.1);
digitalWrite(PulsPin, HIGH);
delay(sure);
digitalWrite(PulsPin, LOW);
delay(sure);
}