Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define potmeterPin A3
- // defines pins numbers
- const int stepPin = 3;
- const int dirPin = 2;
- int p;
- float delay_time=100;
- void setup() {
- Serial.begin(9600);
- // Sets the two pins as Outputs
- pinMode(stepPin,OUTPUT);
- pinMode(dirPin,OUTPUT);
- // Set Dir to Home switch
- digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
- }
- void loop() {
- p = analogRead(potmeterPin);
- delay_time = map(p,0,923,100,250);
- motorStep(1);
- }
- void motorStep( int MAX){
- for(int x = 0; x < MAX; x++) {
- digitalWrite(stepPin,HIGH);
- delayMicroseconds(delay_time);
- digitalWrite(stepPin,LOW);
- delayMicroseconds(delay_time);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement