-
Notifications
You must be signed in to change notification settings - Fork 0
/
head.cpp
88 lines (64 loc) · 1.84 KB
/
head.cpp
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "head.h"
Head::Head()
{
}
void Head::pins(int channelPin, int relayForwardRotation, int relayBackwardRotation)
{
pinMode(channelPin, INPUT);
_channelPin = channelPin;
pinMode(relayForwardRotation, OUTPUT);
_relayForwardRotation = relayForwardRotation;
pinMode(relayBackwardRotation, OUTPUT);
_relayBackwardRotation = relayBackwardRotation;
}
void Head::_testInputValues(int relayForwardRotation)
{
Serial.print("DC Rotating @ value: ");
Serial.println(relayForwardRotation);
};
void Head::checkHeadRotation()
{
//mode 0 = down | Counter-Clockwise motion
//mode 1 = up | Clockwise motion
//mode 2 = nothing | brake
/*
NOOOOOOOOOOOOOOOOOOOOTES
change pulse in pulse to the right input pin
!!!!!!!!!!!!!!!!!!!!!!
*/
int relayForwardRotation = pulseInPlus(_channelPin);
//_testInputValues(relayForwardRotation);
_checkRotationConditionals(relayForwardRotation);
}
void Head::_checkRotationConditionals(int relayForwardRotation)
{
int mode = DialValue(relayForwardRotation);
/*
_relayBackwardRotation - is relay ___
_relayForwardRotation - is relay ___ 1 or 2
_relayBackwardRotation - backwards - when ___
_relayForwardRotation - forward- when ___
*/
if(mode == 0)
{
//For Anti Clock-wise motion, moving the head down
Serial.println("Moving The Head Down!");
digitalWrite(_relayBackwardRotation,1) ;
digitalWrite(_relayForwardRotation,0) ;
}
else if(mode == 1)
{
//For Clock wise motion, moving the head up
Serial.println("Moving The Head Up!");
digitalWrite(_relayBackwardRotation,0) ;
digitalWrite(_relayForwardRotation,1) ;
}
//mode 2 nothing
else
{
Serial.println("Head is Not Moving!");
//For brake
digitalWrite(_relayBackwardRotation,1) ;
digitalWrite(_relayForwardRotation,1) ;
}
}