From 17b159c805e77f5aa06f7881cd50b971079bd314 Mon Sep 17 00:00:00 2001
From: Danisha Ameera Binti Darman Azman <dada1g21@soton.ac.uk>
Date: Tue, 18 Feb 2025 11:15:16 +0000
Subject: [PATCH] Update_2 wifi-test.ino -

---
 wifi-test/wifi-test.ino | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/wifi-test/wifi-test.ino b/wifi-test/wifi-test.ino
index 2cba06a..bba90ed 100644
--- a/wifi-test/wifi-test.ino
+++ b/wifi-test/wifi-test.ino
@@ -13,32 +13,31 @@ int status = WL_IDLE_STATUS;
 WiFiServer server(80);
 
 // Create servo objects
-Servo thumb;
-Servo index;
+Servo index_f;
 Servo middle;
 Servo ring;
 Servo pinky;
 
 // Servo pins
-const int thumbPin = 2;
-const int indexPin = 3;
+
+const int indexPin = 5;
 const int middlePin = 4;
-const int ringPin = 5;
-const int pinkyPin = 6;
+const int ringPin = 3;
+const int pinkyPin = 2;
 
 void setup() {
   Serial.begin(9600);
   
   // Initialize servos
-  thumb.attach(thumbPin);
-  index.attach(indexPin);
+ 
+  index_f.attach(indexPin);
   middle.attach(middlePin);
   ring.attach(ringPin);
   pinky.attach(pinkyPin);
   
   // Set initial positions
-  thumb.write(90);
-  index.write(90);
+
+  index_f.write(90);
   middle.write(90);
   ring.write(90);
   pinky.write(90);
@@ -96,6 +95,7 @@ void loop() {
 }
 
 void processCommand(String command) {
+  Serial.println(command);
   // Extract finger and angle from command
   int firstSlash = command.indexOf('/');
   int secondSlash = command.indexOf('/', firstSlash + 1);
@@ -106,11 +106,11 @@ void processCommand(String command) {
     int angle = command.substring(secondSlash + 1, space).toInt();
     
     // Constrain angle between 0 and 180
-    angle = constrain(angle, 0, 180);
+    angle = constrain(angle, 0, 90);
     
     // 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 == "ring") ring.write(angle);
     else if (finger == "pinky") pinky.write(angle);
-- 
GitLab