This is an old revision of the document!


Projekt 3 Analoog näidik samm-mootoriga

Näide 1

 
/* Description
 
 
*/
 
#include <AccelStepper.h>
 
#define motorPin1  8     // Blue   - 28BYJ48 pin 1
#define motorPin2  9     // Pink   - 28BYJ48 pin 2
#define motorPin3  10    // Yellow - 28BYJ48 pin 3
#define motorPin4  11    // Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)
 
// NOTE: The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper1(8, motorPin1, motorPin3, motorPin2, motorPin4);
 
int posArray[] = {0,    800,  0,    800,  0,    800,  1500, 3000, 2000, 1000, 3000};
int accArray[] = {1000, 3000, 1000, 3000, 1000, 3000, 2000, 2000, 1000, 1000, 3000};
 
void setup()
{
  Serial.begin(9600);
  stepper1.setMaxSpeed(2000.0);
  stepper1.setAcceleration(10000.0);
  stepper1.setSpeed(100);
}
 
void loop(){
 // pote = analogRead(A0)*6;
  for(int i = 0; i<sizeof(posArray); i++){
    stepper1.moveTo(posArray[i]);
    stepper1.setAcceleration(accArray[i]);
    while(stepper1.currentPosition() != posArray[i]){
       stepper1.run();
    }
  }
}
et/arduino/motors/project4.1483618256.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0