Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VRB_QA_REPORT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
atlas-itk-dcs
VRB_QA_REPORT
Commits
67e74ea7
Commit
67e74ea7
authored
1 year ago
by
Samuel Rodriguez Ochoa
Browse files
Options
Downloads
Patches
Plain Diff
Delete mux_control_1st_Version.ino
parent
41584400
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mux_control_1st_Version.ino
+0
-147
0 additions, 147 deletions
mux_control_1st_Version.ino
with
0 additions
and
147 deletions
mux_control_1st_Version.ino
deleted
100644 → 0
+
0
−
147
View file @
41584400
//FUNCTION HEADER
void
setup_pin
();
void
setup_values
();
void
WriteChannel
(
int
*
Port
,
int
channel
);
void
portStatus
();
//GLOBAL VARIABLES
//PIN POSITIONS (ARDUINO HARDWARE PINS)
int
P_positions
[
8
]
=
{
23
,
25
,
27
,
29
,
31
,
33
,
35
,
37
};
//A0 A1 A2 A3 A4 EN WR CS
//LOGIC OUTPUT VLAUES
int
L_values
[
8
]
=
{
0
,
0
,
0
,
0
,
0
,
//A0 A1 A2 A3 A4
0
,
0
,
0
};
// EN WR CS
//LOOP VARIABLES
char
Pin_values
[
2
];
int
count
=
0
;
int
converter
=
0
;
//SETUP FUNCTION
void
setup
()
{
//OUTPUT PINS AVAILABLE
setup_pin
();
//LOGIC VALUES THAT WILL BE WRITTEN IN EVERY PIN
WriteChannel
(
L_values
,
0
);
//LOGIC VALUES WRITING
setup_values
();
//COMMUNICATION RATE
Serial
.
begin
(
9600
);
}
//LOOP FUNCTION
void
loop
()
{
if
(
count
<
2
){
// IF COUNT WASNT 2
//LOOK FOR AVAILABLE SERIAL SIGNAL
if
(
Serial
.
available
()){
Pin_values
[
count
]
=
Serial
.
read
();
//STORAGE THE VALUE
count
++
;
//COUNT INCREASES
if
(
Pin_values
[
0
]
==
'\n'
)
//SPACE FILTER
count
=
0
;
//RESET IF FIRST SPACE IS FOUND
if
(
Pin_values
[
1
]
==
13
)
//SPACE FILTER
count
++
;
}
}
else
{
//IF COUNT WAS 2 OR MORE
//CHECK FOR STATES CHANGES
// EN CHANGE
if
(
Pin_values
[
0
]
==
'e'
&&
Pin_values
[
1
]
==
'n'
){
L_values
[
5
]
=!
L_values
[
5
];
Serial
.
print
(
"enable state uploaded: "
);
Serial
.
println
(
L_values
[
5
]);
portStatus
();
count
=
0
;
//RESET
}
// WR CHANGE
else
if
(
Pin_values
[
0
]
==
'w'
&&
Pin_values
[
1
]
==
'r'
){
L_values
[
6
]
=!
L_values
[
6
];
Serial
.
print
(
"write state uploaded: "
);
Serial
.
println
(
L_values
[
6
]);
portStatus
();
count
=
0
;
//RESET
}
// CS CHANGE
else
if
(
Pin_values
[
0
]
==
'c'
&&
Pin_values
[
1
]
==
's'
){
L_values
[
7
]
=!
L_values
[
7
];
Serial
.
print
(
"write state uploaded: "
);
Serial
.
println
(
L_values
[
7
]);
portStatus
();
count
=
0
;
//RESET
}
//IF THERE IS NO CHANGES WRITE THE CHANNEL SELECTED IN
//SOFTWARE AND HARDWARE
else
{
if
(
Pin_values
[
1
]
==
'\n'
){
//SPACE CORRECTION
Pin_values
[
1
]
=
Pin_values
[
0
];
//ORDER CHANGE
Pin_values
[
0
]
=
48
;
//NULL CHARACTER
}
//THEN DO THE PRINT
Serial
.
print
(
"Channel selected: "
);
//ARGUMENT
Serial
.
print
(
Pin_values
[
0
]);
// FIRST PART
Serial
.
println
(
Pin_values
[
1
]);
// SECOND PART
count
=
0
;
//RESET
//CHAR TO INT AND MULTIPLEXER SYNTAX (1-32 CHANNEL)
converter
=
10
*
(
Pin_values
[
0
]
-
48
)
+
(
Pin_values
[
1
]
-
48
)
-
1
;
WriteChannel
(
L_values
,
converter
);
//SOFTWARE WRITING
}
setup_values
();
//HARDWARE WRITING
}
}
//FUNCTION DEFINITION
//FUNCTION TO WIRITE THE LOGIC VALUES FOR THE CHANNEL SELECTION
void
WriteChannel
(
int
*
Port
,
int
channel
){
//WRITE LOGIC VALUES IN THE ARRAGE
for
(
int
n
=
0
;
n
<
5
;
n
++
){
Port
[
n
]
=
channel
%
2
;
channel
=
channel
/
2
;
}
}
// PRINT THE NEW PORT AFTER DOING SOME KIND OF SETTING
void
portStatus
(){
Serial
.
print
(
"new port state: "
);
Serial
.
print
(
L_values
[
4
]);
Serial
.
print
(
L_values
[
3
]);
Serial
.
print
(
L_values
[
2
]);
Serial
.
print
(
L_values
[
1
]);
Serial
.
print
(
L_values
[
0
]);
Serial
.
print
(
"(A4 A3 A2 A1 A0) "
);
Serial
.
print
(
L_values
[
5
]);
Serial
.
print
(
L_values
[
6
]);
Serial
.
print
(
L_values
[
7
]);
Serial
.
println
(
"(EN WR CS)"
);
}
void
setup_pin
(){
//PIN OUT
pinMode
(
P_positions
[
0
],
OUTPUT
);
pinMode
(
P_positions
[
1
],
OUTPUT
);
pinMode
(
P_positions
[
2
],
OUTPUT
);
pinMode
(
P_positions
[
3
],
OUTPUT
);
pinMode
(
P_positions
[
4
],
OUTPUT
);
pinMode
(
P_positions
[
5
],
OUTPUT
);
pinMode
(
P_positions
[
6
],
OUTPUT
);
pinMode
(
P_positions
[
7
],
OUTPUT
);
}
void
setup_values
(){
//pIN VALUES
digitalWrite
(
P_positions
[
0
],
L_values
[
0
]);
digitalWrite
(
P_positions
[
1
],
L_values
[
1
]);
digitalWrite
(
P_positions
[
2
],
L_values
[
2
]);
digitalWrite
(
P_positions
[
3
],
L_values
[
3
]);
digitalWrite
(
P_positions
[
4
],
L_values
[
4
]);
digitalWrite
(
P_positions
[
5
],
L_values
[
5
]);
digitalWrite
(
P_positions
[
6
],
L_values
[
6
]);
digitalWrite
(
P_positions
[
7
],
L_values
[
7
]);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment