-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZ_applyspeed.ino
More file actions
25 lines (24 loc) · 899 Bytes
/
Z_applyspeed.ino
File metadata and controls
25 lines (24 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
*
* Function Name: applyspeed()
* Input: none
* Output: speed and direction of the motor
* Logic: here if the speed of motor is positive the one direction and the negative then another direction and default for stop the motion
* Example Call: applyspeed()
*
*/
void applyspeed()
{
switch (spd1)
{
case -255 ... -1: analogWrite(mot1, -spd1); digitalWrite(mot11 , HIGH); break;
case 1 ... 255: analogWrite(mot1, spd1); digitalWrite(mot11 , LOW); break;
default: analogWrite(mot1, 0); digitalWrite(mot11 , LOW); break;
}
switch (spd2)
{
case -255 ... -1: analogWrite(mot2, -spd2); digitalWrite(mot21 , LOW); break;
case 1 ... 255: analogWrite(mot2, spd2); digitalWrite(mot21 , HIGH); break;
default: analogWrite(mot2, 0); digitalWrite(mot21 , LOW); break;
}
}