Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.8 kB
76
Indexable
Never
float f=50;
float t=(1/f)*1000000;
float a1=17.9178;
float a2=57.4096;
float a1p1=(a1*t)/360;
float a1p2=(a2*t)/360;
float d=5;

int pin1=9;
int pin2=2;
int pin3=3;
int pin4=4;
int pin5=5;
int pin6=6;
int pin7=7;
int pin8=8;

void setup(){
  Serial.begin(9600);
  pinMode(pin1, OUTPUT);
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
  pinMode(pin4, OUTPUT);
  pinMode(pin5, OUTPUT);
  pinMode(pin6, OUTPUT);
  pinMode(pin7, OUTPUT);
  pinMode(pin8, OUTPUT);
}

void loop(){
 
  
  digitalWrite(pin1,HIGH);
  digitalWrite(pin2,HIGH);
  digitalWrite(pin5,HIGH);
  digitalWrite(pin6,HIGH);
  delayMicroseconds(a1p1-d);                                                                                                                                                                                                                                   

  digitalWrite(pin2, LOW);
  delayMicroseconds(d);
  digitalWrite(pin4,HIGH);
  delayMicroseconds(a1p2-a1p1-d);

  digitalWrite(pin6,LOW);
  delayMicroseconds(d);
  digitalWrite(pin8,HIGH);
  delayMicroseconds(t/2-(2*a1p2)-d);

  digitalWrite(pin5,LOW);
  delayMicroseconds(d);
  digitalWrite(pin7,HIGH);
  delayMicroseconds(a1p2-a1p1-d);

   digitalWrite(pin1,LOW);
   delayMicroseconds(d);
   digitalWrite(pin3,HIGH);
   delayMicroseconds((2*a1p1)-d);

   digitalWrite(pin4,LOW);
   delayMicroseconds(d);
   digitalWrite(pin2,HIGH);
   delayMicroseconds(a1p2-a1p1-d);

   digitalWrite(pin8,LOW);
   delayMicroseconds(d);
   digitalWrite(pin6,HIGH);
   delayMicroseconds(t/2-(2*a1p2)-d);

   digitalWrite(pin7,LOW);
   delayMicroseconds(d);
   digitalWrite(pin5,HIGH);
   delayMicroseconds(a1p2-a1p1-d);

   digitalWrite(pin3,LOW);
   delayMicroseconds(d);
   digitalWrite(pin1,HIGH);
   delayMicroseconds(a1p1);
}