0% found this document useful (0 votes)
113 views3 pages

Functions 1

The document contains definitions for several functions related to motor control. It defines functions for shutting down all outputs, controlling two terminals (A and B) in either normal or reversed polarity, and performing full-step and half-step clockwise and counterclockwise motor control by sequentially activating the two terminals in different combinations with delays.

Uploaded by

api-526076334
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views3 pages

Functions 1

The document contains definitions for several functions related to motor control. It defines functions for shutting down all outputs, controlling two terminals (A and B) in either normal or reversed polarity, and performing full-step and half-step clockwise and counterclockwise motor control by sequentially activating the two terminals in different combinations with delays.

Uploaded by

api-526076334
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Functions 

void shutdown()​ {   
digitalWrite(12,LOW);   
digitalWrite(3,LOW); 
digitalWrite(13,LOW);   
digitalWrite(11,LOW); 

void terminal_A(int polarity) ​{ 


if (polarity==NORTH){ 
digitalWrite(A_DIRECTION, HIGH);   
digitalWrite(A, HIGH); 

if (polarity==SOUTH) { 
digitalWrite(A_DIRECTION, LOW); 
digitalWrite(A, HIGH); 

else { 
digitalWrite(A_DIRECTION, LOW); 
digitalWrite(A, LOW); 

void terminal_B(int polarity)​ { 


if (polarity==NORTH){ 
digitalWrite(B_DIRECTION, HIGH);   
digitalWrite(B, HIGH); 

if (polarity==SOUTH){ 
digitalWrite(B_DIRECTION, LOW); 
digitalWrite(B, HIGH); 

else { 
digitalWrite(B_DIRECTION, LOW); 
digitalWrite(B, LOW); 

//START OF FULL STEP FUNCTIONS 


void full_step_CCW(int d)​ {   
terminal_A(SOUTH); 
terminal_B(OFF);   
delay(d); 
terminal_A(OFF); 
terminal_B(SOUTH); 
delay(d); 
terminal_A(NORTH); 
terminal_B(OFF);   
delay(d); 
terminal_A(OFF); 
terminal_B(NORTH); 
delay(d); 

void full_step_CW(int d)​ { 


terminal_A(SOUTH); 
terminal_B(OFF); 
delay(d); 
terminal_A(OFF); 
terminal_B(NORTH);   
delay(d); 
terminal_A(NORTH); 
terminal_B(OFF); 
delay(d); 
terminal_A(OFF); 
terminal_B(SOUTH);   
delay(d); 

//START OF HALF STEP FUNCTIONS 


void half_step_CCW(int d)​ ​{   
terminal_A(SOUTH); 
terminal_B(OFF); 
delay(d); 
terminal_A(SOUTH); 
terminal_B(SOUTH); 
delay(d); 
terminal_A(OFF); 
terminal_B(SOUTH); 
delay(d);   
terminal_A(NORTH); 
terminal_B(SOUTH); 
delay(d); 
terminal_A(NORTH); 
terminal_B(OFF); 
delay(d); 
terminal_A(SOUTH); 
terminal_B(NORTH); 
delay(d); 
terminal_A(OFF); 
terminal_B(NORTH); 
delay(d); 
terminal_A(NORTH); 
terminal_B(NORTH);   
delay(d); 

void half_step_CW(int d)​ { 


terminal_A(SOUTH); 
terminal_B(OFF); 
delay(d); 
terminal_A(SOUTH); 
terminal_B(NORTH); 
delay(d); 
terminal_A(OFF); 
terminal_B(NORTH); 
delay(d); 
terminal_A(NORTH);   
terminal_B(NORTH); 
delay(d); 
terminal_A(NORTH); 
terminal_B(OFF); 
delay(d); 
terminal_A(SOUTH); 
terminal_B(SOUTH); 
delay(d); 
terminal_A(OFF); 
terminal_B(SOUTH); 
delay(d); 
terminal_A(NORTH); 
terminal_B(SOUTH); 
delay(d); 
}

You might also like