Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Arduino Codes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Medics
Arduino Codes
Commits
17b159c8
Commit
17b159c8
authored
2 months ago
by
Danisha Ameera Binti Darman Azman
Browse files
Options
Downloads
Patches
Plain Diff
Update_2 wifi-test.ino -
parent
5ee205f7
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
wifi-test/wifi-test.ino
+13
-13
13 additions, 13 deletions
wifi-test/wifi-test.ino
with
13 additions
and
13 deletions
wifi-test/wifi-test.ino
+
13
−
13
View file @
17b159c8
...
@@ -13,32 +13,31 @@ int status = WL_IDLE_STATUS;
...
@@ -13,32 +13,31 @@ int status = WL_IDLE_STATUS;
WiFiServer
server
(
80
);
WiFiServer
server
(
80
);
// Create servo objects
// Create servo objects
Servo
thumb
;
Servo
index_f
;
Servo
index
;
Servo
middle
;
Servo
middle
;
Servo
ring
;
Servo
ring
;
Servo
pinky
;
Servo
pinky
;
// Servo pins
// Servo pins
const
int
thumbPin
=
2
;
const
int
indexPin
=
3
;
const
int
indexPin
=
5
;
const
int
middlePin
=
4
;
const
int
middlePin
=
4
;
const
int
ringPin
=
5
;
const
int
ringPin
=
3
;
const
int
pinkyPin
=
6
;
const
int
pinkyPin
=
2
;
void
setup
()
{
void
setup
()
{
Serial
.
begin
(
9600
);
Serial
.
begin
(
9600
);
// Initialize servos
// Initialize servos
thumb
.
attach
(
thumbPin
);
index
.
attach
(
indexPin
);
index
_f
.
attach
(
indexPin
);
middle
.
attach
(
middlePin
);
middle
.
attach
(
middlePin
);
ring
.
attach
(
ringPin
);
ring
.
attach
(
ringPin
);
pinky
.
attach
(
pinkyPin
);
pinky
.
attach
(
pinkyPin
);
// Set initial positions
// Set initial positions
thumb
.
write
(
90
);
index
.
write
(
90
);
index
_f
.
write
(
90
);
middle
.
write
(
90
);
middle
.
write
(
90
);
ring
.
write
(
90
);
ring
.
write
(
90
);
pinky
.
write
(
90
);
pinky
.
write
(
90
);
...
@@ -96,6 +95,7 @@ void loop() {
...
@@ -96,6 +95,7 @@ void loop() {
}
}
void
processCommand
(
String
command
)
{
void
processCommand
(
String
command
)
{
Serial
.
println
(
command
);
// Extract finger and angle from command
// Extract finger and angle from command
int
firstSlash
=
command
.
indexOf
(
'/'
);
int
firstSlash
=
command
.
indexOf
(
'/'
);
int
secondSlash
=
command
.
indexOf
(
'/'
,
firstSlash
+
1
);
int
secondSlash
=
command
.
indexOf
(
'/'
,
firstSlash
+
1
);
...
@@ -106,11 +106,11 @@ void processCommand(String command) {
...
@@ -106,11 +106,11 @@ void processCommand(String command) {
int
angle
=
command
.
substring
(
secondSlash
+
1
,
space
).
toInt
();
int
angle
=
command
.
substring
(
secondSlash
+
1
,
space
).
toInt
();
// Constrain angle between 0 and 180
// Constrain angle between 0 and 180
angle
=
constrain
(
angle
,
0
,
18
0
);
angle
=
constrain
(
angle
,
0
,
9
0
);
// Move appropriate servo
// Move appropriate servo
if
(
finger
==
"thumb"
)
thumb
.
write
(
angle
);
else
if
(
finger
==
"index"
)
index
.
write
(
angle
);
if
(
finger
==
"index"
)
index
_f
.
write
(
angle
);
else
if
(
finger
==
"middle"
)
middle
.
write
(
angle
);
else
if
(
finger
==
"middle"
)
middle
.
write
(
angle
);
else
if
(
finger
==
"ring"
)
ring
.
write
(
angle
);
else
if
(
finger
==
"ring"
)
ring
.
write
(
angle
);
else
if
(
finger
==
"pinky"
)
pinky
.
write
(
angle
);
else
if
(
finger
==
"pinky"
)
pinky
.
write
(
angle
);
...
...
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