Tải bản đầy đủ - 0 (trang)
Code điều khiển theo hướng hình xoắn ốc

Code điều khiển theo hướng hình xoắn ốc

Tải bản đầy đủ - 0trang

pinMode(13,OUTPUT);//dir

digitalWrite(12,HIGH);

}

void quatrai1(){

//437.5mm

for(long i=0;i<=175000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);// mo nguon

digitalWrite(8,HIGH);//chieu dong co

digitalWrite(6,HIGH);//xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void len1(){

//350mm

for(int a=0;a<=140000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,HIGH);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quaphai1(){

//437.5mm

47



for(long i=0;i<=175000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);//enb mo nguon

digitalWrite(8,LOW);//dir chieu dong co

digitalWrite(6,HIGH);//step xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void xuong1(){

//300mm

for(int a=0;a<=120000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,LOW);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quatrai2(){

//387.5mm

for(long i=0;i<=155000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);// mo nguon

digitalWrite(8,HIGH);//chieu dong co

48



digitalWrite(6,HIGH);//xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void len2(){

//300mm

for(int a=0;a<=120000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,HIGH);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quaphai2(){

//387.5mm

for(long i=0;i<=155000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);//enb mo nguon

digitalWrite(8,LOW);//dir chieu dong co

digitalWrite(6,HIGH);//step xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

49



}

void xuong2(){

//250mm

for(int a=0;a<=100000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,LOW);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quatrai3(){

//337.5mm

for(long i=0;i<=135000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);// mo nguon

digitalWrite(8,HIGH);//chieu dong co

digitalWrite(6,HIGH);//xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void len3(){

//250mm

for(int a=0;a<=100000;a++)

{

50



//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,HIGH);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quaphai3(){

//337.5mm

for(long i=0;i<=135000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);//enb mo nguon

digitalWrite(8,LOW);//dir chieu dong co

digitalWrite(6,HIGH);//step xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void xuong3(){

//200mm

for(int a=0;a<=80000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,LOW);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

51



digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quatrai4(){

//287.5mm

for(long i=0;i<=115000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);// mo nguon

digitalWrite(8,HIGH);//chieu dong co

digitalWrite(6,HIGH);//xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void len4(){

//200mm

for(int a=0;a<=80000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,HIGH);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quaphai4(){

52



//287.5

for(long i=0;i<=115000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);//enb mo nguon

digitalWrite(8,LOW);//dir chieu dong co

digitalWrite(6,HIGH);//step xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void xuong4(){

//150mm

for(int a=0;a<=60000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,LOW);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quatrai5(){

//237.5mm

for(long i=0;i<=95000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);// mo nguon

53



digitalWrite(8,HIGH);//chieu dong co

digitalWrite(6,HIGH);//xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void len5(){

//150mm

for(int a=0;a<=60000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,HIGH);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quaphai5(){

//237.5

for(long i=0;i<=95000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);//enb mo nguon

digitalWrite(8,LOW);//dir chieu dong co

digitalWrite(6,HIGH);//step xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

54



}

}

void xuong5(){

//100mm

for(int a=0;a<=40000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,LOW);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quatrai6(){

//187.5mm

for(long i=0;i<=75000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);// mo nguon

digitalWrite(8,HIGH);//chieu dong co

digitalWrite(6,HIGH);//xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void len6(){

//100mm

for(int a=0;a<=40000;a++)

55



{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,HIGH);//dir

digitalWrite(5,HIGH);//xung

delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void quaphai6(){

//187.5

for(long i=0;i<=75000;i++)

{

//digitalWrite(10,HIGH);

digitalWrite(7,LOW);//enb mo nguon

digitalWrite(8,LOW);//dir chieu dong co

digitalWrite(6,HIGH);//step xung

delayMicroseconds(50);

digitalWrite(6,LOW);//xung

delayMicroseconds(30);

}

}

void xuong6(){

//50mm

for(int a=0;a<=20000;a++)

{

//digitalWrite(7,HIGH);

digitalWrite(9,LOW);//enb

digitalWrite(4,LOW);//dir

digitalWrite(5,HIGH);//xung

56



delayMicroseconds(150);

digitalWrite(5,LOW);//xung

delayMicroseconds(150);

}

}

void tien(){

for (int x=0;x<=10000;x++){

digitalWrite(12,LOW);

digitalWrite(13,LOW);//dir

digitalWrite(10,HIGH);

delayMicroseconds(100);

digitalWrite(10,LOW);

delayMicroseconds(100);

}

}

void lui(){

for (int x=0;x<=10000;x++){

digitalWrite(12,LOW);

digitalWrite(13,HIGH);//dir

digitalWrite(10,HIGH);

delayMicroseconds(100);

digitalWrite(10,LOW);

delayMicroseconds(100);

}

}

void loop() {

tien();

digitalWrite(2,0);

quatrai1();

len1();

quaphai1();

57



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Code điều khiển theo hướng hình xoắn ốc

Tải bản đầy đủ ngay(0 tr)

×