Robotika ● שיעור 6Lesson 6
→ חזרה← Back
קורס ארדואינו · מפגשים 6–7Arduino course · Sessions 6–7

זרוע רובוטית 🦾
סרוו, כוח ובקרה
Robotic arm 🦾
Servos, power & control

הפרויקט הכי "רובוטי" עד כה: 4 מנועי סרוו ותושבות מתכת הופכים לזרוע עם 4 מפרקים. נלמד מה זה סרוו לעומק, איך מזינים אותו בכוח בלי לשרוף כלום, נבנה את הזרוע — ונלמד אותה לזוז. The most "robot" project yet: 4 servo motors and metal brackets become a 4-joint arm. We'll learn what a servo really is, how to power it without frying anything, build the arm — and teach it to move.

מפגש 6Session 6 — סרוו + בנייה + שליטה במפרקservos + build + joint control
מפגש 7Session 7 — תנועה חלקה, תנוחות, שלטsmooth motion, poses, remote
RDS3115 — סרוו דיגיטלי 15 ק"ג·ס"מ ×4digital 15 kg·cm servo ×4

ניווט: חצים ← → במקלדת, או הכפתורים למטה · לחצו EN לבדיקת מונחים באנגלית Navigate: ← → arrow keys, or the buttons below · press עב for Hebrew

2התוכנית — שני מפגשיםThe plan — two sessions

מפגש 6 — הבסיס והבנייהSession 6 — basics & build

  • מה זה סרוו, ואיך הוא שונה ממנוע רגילWhat a servo is, and how it differs from a plain motor
  • איך מדברים אליו בקוד (ספריית Servo)How to talk to it in code (the Servo library)
  • ⚡ בעיית הכוח — למה 4 סרוו ≠ כבל USB⚡ The power problem — why 4 servos ≠ a USB cable
  • מרכיבים את הזרוע מהסרוו והתושבותAssemble the arm from servos and brackets
  • יעד: כל מפרק זז לזווית שאנחנו מבקשיםGoal: every joint moves to the angle we ask for

מפגש 7 — שהזרוע תעשה משהוSession 7 — make it do something

  • תנועה חלקה במקום קפיצותSmooth motion instead of jumps
  • "שלט לימוד" — פוטנציומטרים שמניחים תנוחהA "teach pendant" — pots that pose the arm
  • הקלטה והשמעה של תנוחות = הרם-והנחRecord & replay poses = pick-and-place
  • שליטה מהטלפון / ממרכז השליטה (שיעור 5)Control from the phone / command center (Lesson 5)
יכול להיות שלא נספיק הכול במפגש 6 — וזה בסדר. הכול כאן בשקופיות ובקבצי הקוד.We may not finish everything in Session 6 — that's fine. It's all here in the slides and the code files.

3חוקי זהב — קוראים לפני שמתחילים ⚠️Golden rules — read before we start ⚠️

הכללים קודם; ההסברים מגיעים בהמשך השיעור. אם זוכרים רק שקופית אחת — שתהיה זו.Rules first; the reasons come later in the lesson. If you remember only one slide — make it this one.

⚡ חשמל וכוח⚡ Power & electrical

  • מזינים את הסרוו מספק חיצוני 5–6V — לא מה-5V של הארדואינו ולא מ-USBPower the servos from an external 5–6V supply — not the Arduino's 5V, not USB
  • גראונד משותף תמיד — GND של הספק מחובר ל-GND של הארדואינוAlways a common ground — the supply's GND tied to the Arduino's GND
  • מחברים הכול כשהכוח מכובה; מדליקים את הספק החיצוני אחרוןWire everything with power off; turn the external supply on last
  • נשארים בטווח המתח 4.8–6VStay within the 4.8–6V range

🦾 מכאניקה וידיים🦾 Mechanics & hands

  • לא מסובבים ציר סרוו ביד כשיש כוחNever turn a servo shaft by hand while it's powered
  • אצבעות הרחק מהמפרקים ומהתפסן בזמן תנועה (נקודות צביטה)Keep fingers clear of joints and the gripper while it moves (pinch points)
  • מאפסים ל-90° בקוד לפני שמחברים דיסקיות ותושבותCenter to 90° in code before attaching horns and brackets
  • מגבילים זוויות בקוד עם constrain()Limit angles in code with constrain()
  • מחזיקים את הזרוע ביד בהדלקה הראשונהHold the arm by hand on the first power-up
אם הארדואינו מתאתחל כשהסרוו זזים, או שהסרוו רועד ומשתגע — מכבים מיד ובודקים ספק כוח וגראונד משותף.If the Arduino resets when servos move, or a servo jitters and goes wild — power off at once and check the supply and the common ground.

4מה זה בעצם סרוו?What exactly is a servo?

מנוע רגיל (כמו במכונית) יודע רק להסתובב — מהר, לאט, קדימה, אחורה. הוא לא יודע איפה הוא נמצא. סרוו הוא חיה אחרת: אתם אומרים לו זווית (נניח 90°), והוא הולך לשם ונשאר שם. A plain motor (like in the car) only knows how to spin — fast, slow, forward, back. It has no idea where it is. A servo is a different animal: you tell it an angle (say 90°) and it goes there and stays there.

הסוד: בתוך הקופסה הקטנה יש ארבעה דברים יחד —The secret: inside that little box there are four things together —

  • ⚙️ מנוע קטן + גלגלי שיניים (ב-RDS3115 ממתכת) שמגבירים כוח⚙️ a small motor + gears (metal on the RDS3115) that multiply force
  • 🎚️ פוטנציומטר שמרגיש את הזווית הנוכחית של הציר🎚️ a potentiometer that senses the shaft's current angle
  • 🧠 מעגל בקרה שמשווה "איפה אני" ל"לאן ביקשו"🧠 a control circuit comparing "where I am" to "where I was told"
בגלל זה סרוו מחזיק תנוחה גם כשדוחפים אותו — הוא כל הזמן מתקן את עצמו.That's why a servo holds a pose even when pushed — it keeps correcting itself.

גררו את הזווית — הסרוו "הולך" לשם:Drag the angle — the servo "goes" there:

write(90)

5שלושה חוטים, ואיך "אומרים" זוויתThree wires, and how you "say" an angle

שלושת החוטיםThe three wires

צבעColorתפקידRole
חום / שחורBrown / blackGND (−)
אדוםRedכוחPower V+ (5–6V)
כתום / צהובOrange / yellowאות (Signal) — מהארדואינוSignal — from the Arduino

הכוח לא בא מפין האות. האות הוא רק הוראה דקה: פעימה חשמלית שחוזרת כל 20 מילישניות (50 פעמים בשנייה). אורך הפעימה הוא הזווית: Power does not come from the signal pin. The signal is just a thin instruction: a pulse that repeats every 20 ms (50 times a second). The pulse's length is the angle:

  • ~1000µs → 0°
  • ~1500µs → 90° (אמצעcenter)
  • ~2000µs → 180°
הטוב שבכל זה: את כל חישוב הפעימות עושה ספריית Servo. אתם רק כותבים write(90).The good news: the Servo library does all this pulse math. You just write write(90).

גררו את אורך הפעימה — וראו את הזווית:Drag the pulse length — and watch the angle:

1500µs → 90°

6הלולאה הפנימית — למה הוא "מחזיק"The inner loop — why it "holds"

כל כמה מילישניות הסרוו עושה את אותו דבר:Every few milliseconds the servo does the same thing:

  1. קורא את הזווית שביקשתם (מאורך הפעימה)Reads the angle you asked for (from the pulse length)
  2. קורא את הזווית האמיתית (מהפוטנציומטר הפנימי)Reads the real angle (from its internal pot)
  3. אם יש פער — מפעיל את המנוע לכיוון שסוגר אותוIf there's a gap — drives the motor to close it

זו "בקרת משוב" (closed-loop). בגלל זה:That's closed-loop control. Because of it:

  • הוא נלחם בעומס — דחיפה = הוא דוחף בחזרה (וצורך יותר זרם)It fights a load — push it and it pushes back (drawing more current)
  • לפעמים הוא מזמזם/רועד — הוא מתקן פער זעיר הלוך-ושובSometimes it buzzes/jitters — correcting a tiny gap back and forth
⚠️ אל תסובבו את ציר הסרוו ביד כשהוא מחובר לכוח — זה דוחף את המנוע לאחור ועלול לפגוע בו. מסובבים ביד רק כשהכוח מנותק.⚠️ Don't turn the servo's shaft by hand while it's powered — it back-drives the motor and can damage it. Turn by hand only with power off.

מנוע רגיל מול סרווPlain motor vs servo

מנוע DC (המכונית)DC motor (the car)Servo
מה שולטיםYou controlמהירות/כיווןspeed/directionזוויתangle
יודע איפה הוא?Knows where it is?לאNoכןYes
צריך מגשר (L298N)?Needs an H-bridge?כןYesלאNo
מחזיק מקום?Holds position?לאNoכןYes

לכן לזרוע צריך סרוו: מפרק חייב להגיע לזווית מדויקת ולהישאר שם תחת משקל.So an arm needs servos: a joint must reach a precise angle and stay there under weight.

7כוח (מומנט), טווח וסוגיםTorque, reach & types

כוח של סרוו נמדד בק"ג·ס"מ (מומנט). ה-RDS3115 נותן ~15 ק"ג·ס"מ ב-6V. פירושו: הוא יכול להחזיק 15 ק"ג במרחק 1 ס"מ מהציר — אבל רק ~1 ק"ג במרחק 15 ס"מ. A servo's strength is measured in kg·cm (torque). The RDS3115 gives ~15 kg·cm at 6V. Meaning: it can hold 15 kg at 1 cm from the shaft — but only ~1 kg at 15 cm.

זה למה הזרוע היותר ארוכה = יותר חלשה בקצה. מפרק הכתף (שנושא את כל השאר) עובד הכי קשה. That's why a longer arm = weaker at the tip. The shoulder joint (carrying everything else) works hardest.

שני סוגים שחשוב להכירTwo types to know

  • 180° (רגיל): הולך לזווית. זה מה שיש לנו. 🦾180° (standard): goes to an angle. This is what we have. 🦾
  • Continuous (360°): מסתובב בלי סוף — שולטים במהירות, לא בזווית (כמו גלגל).Continuous (360°): spins endlessly — you control speed, not angle (like a wheel).

שלנו: דיגיטלי (אחיזה חזקה ומדויקת) + MG (Metal Gear — גלגלי מתכת עמידים).Ours: digital (strong, precise holding) + MG (Metal Gear — durable metal gears).

גררו את המרחק מהציר — וראו כמה אפשר להרים:Drag the distance from the shaft — see how much it can lift:

מרים עדLifts up to 1.5 ק"גkg

15 kg·cm ÷ מרחקdistance

8שלב 1: להזיז סרוו אחד בקודLevel 1: move one servo in code

ספריית Servo כבר מגיעה עם ה-IDE. שלושה דברים זה כל הסיפור: The Servo library already ships with the IDE. Three things are the whole story:

  • #include <Servo.h> — מביאים את הספרייהbring in the library
  • Servo joint; — אובייקט לכל סרווan object per servo
  • joint.attach(9); ואזthen joint.write(90);

הסקצ' הקלאסי להתחלה — "Sweep": הסרוו מטייל 0→180 וחזרה. אם זה עובד — החיווט והכוח תקינים, ואפשר לבנות. The classic starter — "Sweep": the servo travels 0→180 and back. If it works, your wiring and power are good and you can start building.

💡 write() אומר "לך לזווית הזו". הסרוו מחליט לבד באיזו מהירות — ב-Sweep ה-delay(15) בין צעד לצעד הוא מה שמאט אותו.💡 write() means "go to this angle". The servo picks its own speed — in Sweep the delay(15) between steps is what slows it down.
#include <Servo.h>
Servo joint;              // controls one servo
const int SERVO_PIN = 9;

void setup() {
  joint.attach(SERVO_PIN);
}
void loop() {
  for (int a=0; a<=180; a++){ // 0 -> 180
    joint.write(a);
    delay(15);
  }
  for (int a=180; a>=0; a--){ // back
    joint.write(a);
    delay(15);
  }
}

📄 code/level1_servo_sweep.ino · ואז level2_servo_serial.ino — הקלידו זווית ב-Serial.📄 code/level1_servo_sweep.ino · then level2_servo_serial.ino — type an angle in Serial.

9⚡ בעיית הכוח — הכי חשוב היום⚡ The power problem — today's most important slide

סרוו אחד מסוג RDS3115 יכול למשוך ~2.5 אמפר כשהוא נאבק בעומס. ארבעה ביחד — עד ~10 אמפר לרגע. כבל ה-USB נותן בערך 0.5 אמפר, והמייצב של הארדואינו עוד פחות. One RDS3115 can pull ~2.5 A when fighting a load. Four together — up to ~10 A for a moment. A USB cable gives about 0.5 A, and the Arduino's regulator even less.

❌ להזין 4 סרוו מה-5V של הארדואינו = נפילת מתח: הארדואינו יאותחל שוב ושוב, הסרוו ירעד, ובמקרה גרוע תשרפו את המייצב.❌ Powering 4 servos from the Arduino's 5V = a brown-out: the Arduino resets over and over, servos twitch, and in the worst case you burn the regulator.

הפתרוןThe fix

  • ספק כוח נפרד 5–6V שנותן כמה אמפרים (סוללה טובה / ספק מעבדה / BEC)A separate 5–6V supply that gives several amps (good battery / bench supply / BEC)
  • הכוח הולך לסרוו; הארדואינו נותן רק את חוט האותPower goes to the servos; the Arduino provides only the signal wire
  • גראונד משותף! ה-GND של ספק הסרוו חייב להתחבר ל-GND של הארדואינו — אחרת האות "מרחף" והסרוו משתגע.Common ground! The servo supply's GND must connect to the Arduino's GND — otherwise the signal "floats" and the servo goes crazy.

עם ה-Sensor Shield זה קלWith the Sensor Shield it's easy

זה אותו Sensor Shield משיעורים קודמים — לא "servo shield" עם PCA9685 (שעובד אחרת לגמרי וצריך ספרייה נפרדת).This is the same Sensor Shield from earlier lessons — not a PCA9685 "servo shield" (which works differently and needs a separate library).
  • לשילד יש שורת כוח לסרוו עם בורג-חיבור (V / G) לכוח חיצוניThe shield has a servo power rail with a screw terminal (V / G) for external power
  • מחברים את הסרוו לשלשת הפינים (S / V / G) — האות לפין, הכוח מהשורהPlug each servo into the 3-pin header (S / V / G) — signal to the pin, power from the rail
  • יש ג'מפר שמנתק את כוח הסרוו מ-5V של הארדואינו — ודאו שהוא במצב כוח חיצוניThere's a jumper that disconnects servo power from the Arduino's 5V — set it to external power

10מכירים את החלקיםMeet the parts

לכל תלמיד: 4 סרוו, כמה תושבות אלומיניום (U/L), דיסקיות (horns) וברגים. התכלת־המתכת שבתמונה הן ה"שלד" של הזרוע. Per student: 4 servos, a few aluminum brackets (U/L), horns (disks) and screws. The metal brackets in the photo are the arm's "skeleton".

מה עושה תושבת?What does a bracket do?

תושבת ה-U "עוטפת" סרוו ומחברת אותו לחלק הבא. כך כל סרוו הופך למפרק מסתובב: הגוף של הסרוו קבוע לחלק אחד, והדיסקית (שמסתובבת עם הציר) מחוברת לחלק השני. כשהציר מסתובב — המפרק מתכופף. The U-bracket "wraps" a servo and links it to the next part. That turns each servo into a rotating joint: the servo body is fixed to one part, and the horn (which turns with the shaft) is fixed to the next. When the shaft turns — the joint bends.

💡 ה-RDS3115 מגיע עם תושבת U ארוכה + קצרה בדיוק בשביל זה. התאימו את שלבי הבנייה לערכת התושבות שבידיכם.💡 The RDS3115 ships with a long + short U-bracket exactly for this. Adapt the build steps to the bracket set you have.

סרוו + תושבת = מפרק אחד. ארבעה כאלה = זרוע.servo + bracket = one joint. Four of them = an arm.

11כלל זהב: לאפס ל-90° לפני ההרכבהGolden rule: center to 90° before assembly

לפני שמחברים דיסקית לסרוו — מריצים קוד שמעמיד את כל הסרוו ב-90°. רק אז מרכיבים, כשהמפרק ב"אמצע". Before attaching a horn — run code that sets every servo to 90°. Only then assemble, with the joint at its "middle".

למה? אם תרכיבו מפרק בקצה הטווח, תקבלו תנועה רק לכיוון אחד. מ-90° יש לכם ±90° לכל צד. Why? If you assemble a joint at the end of its range, you only get motion one way. From 90° you have ±90° each way.

  1. מחברים כוח (חיצוני!) ומריצים את סקצ' האיפוסConnect power (external!) and run the centering sketch
  2. מרכיבים את הדיסקית/התושבת כשהמפרק ישר ("אמצע")Attach the horn/bracket with the joint straight ("middle")
  3. מהדקים את בורג הדיסקיתTighten the horn screw
#include <Servo.h>
const int PINS[] = {3,5,6,9};
const int N = 4;
Servo servos[N];

void setup() {
  for (int i=0; i<N; i++){
    servos[i].attach(PINS[i]);
    servos[i].write(90);  // middle
  }
}
void loop() { }   // just hold 90

📄 code/level1_center_all.ino📄 code/level1_center_all.ino

הסרוו רועד קצת כשהוא "מחזיק" 90° — זה תקין. זו הלולאה הפנימית בעבודה.The servo buzzes a little while "holding" 90° — that's normal. It's the inner loop at work.

12בונים את הזרוע — מלמטה למעלהBuild the arm — bottom-up

זרוע עם 4 מפרקים (4 DOF — דרגות חופש). מרכיבים מהבסיס כלפי מעלה, כל סרוו נושא את אלה שמעליו: A 4-joint arm (4 DOF — degrees of freedom). Build from the base up; each servo carries the ones above it:

  • בסיסBase — מסתובב שמאל/ימין (yaw), שוכב שטוחrotates left/right (yaw), lies flat
  • כתףShoulder — המפרק שמרים את כל הזרוע — עובד הכי קשהthe joint that lifts the whole arm — works hardest
  • מרפקElbow — מכופף את החלק הקדמיbends the forearm
  • תפסןGripper — פותח/סוגר בקצה (או מפרק שורש-כף)opens/closes at the tip (or a wrist joint)
⚠️ הסרוו של הבסיס והכתף נושאים הכי הרבה משקל — הדקו אותם חזק ושימו לב שלא יהיה "לופט" במפרק.⚠️ The base and shoulder servos carry the most weight — fasten them well and watch for play in the joint.

4 DOF: בסיס · כתף · מרפק · תפסן4 DOF: base · shoulder · elbow · gripper

13מחברים את 4 הסרווWire the 4 servos

לספריית Servo לא אכפת מאיזה פין — כל פין דיגיטלי מתאים. נשאיר את D0/D1 פנויים ל-Serial, ונבחר ארבעה פינים נוחים בשילד. The Servo library doesn't care which pin — any digital pin works. We keep D0/D1 free for Serial and pick four convenient pins on the shield.

💡 מיתוס נפוץ: הפינים עם ~ (PWM) לא נותנים שליטה טובה יותר בסרוו. ה-analogWrite שלהם הוא גל ריבועי קבוע ~490Hz — לא מה שסרוו צריך. ספריית Servo מייצרת לבד פעימות מדויקות (50Hz, 1000–2000µs) דרך טיימר חומרה, באותו דיוק בכל פין דיגיטלי. (ב-Uno היא אפילו מכבה את ה-PWM בפינים 9 ו-10.)💡 Common myth: the ~ (PWM) pins give no better servo control. Their analogWrite is a fixed ~490Hz square wave — not what a servo wants. The Servo library generates precise pulses itself (50Hz, 1000–2000µs) via a hardware timer, equally precise on any digital pin. (On the Uno it even disables PWM on pins 9 & 10.)
מפרקJointSignal
baseD3
shoulderD5
elbowD6
gripperD9
הכוח (V) של כל ארבעת הסרוו — משורת הכוח החיצונית של השילד, לא מהארדואינו. גראונד משותף!Power (V) for all four servos — from the shield's external power rail, not the Arduino. Common ground!

סדר פעולות ההדלקהPower-up order

  1. מחברים הכול כשהכוח מכובהWire everything with power off
  2. מעלים קוד דרך USB (סרוו עוד לא זזים חזק)Upload code over USB (servos won't move hard yet)
  3. מדליקים את ספק הסרוו החיצוניTurn on the external servo supply
  4. מחזיקים את הזרוע ביד בפעם הראשונה — ליתר ביטחוןHold the arm by hand the first time — just in case
אם הארדואינו מתאתחל כשהסרוו זזים — זו נפילת מתח. בדקו את ספק הכוח ואת הגראונד המשותף.If the Arduino resets when servos move — that's a brown-out. Check the supply and the common ground.

14יעד מפגש 6: שליטה בכל מפרקSession 6 goal: control every joint

גררו את ארבעת המחוונים — וראו את הזרוע זזה:Drag the four sliders — and watch the arm move:

90°
90°
90°
40°

בקוד: פקודה אחת למפרק — "<מפרק> <זווית>". דוגמה: 1 120 = כתף ל-120°. In code: one command per joint — "<joint> <angle>". Example: 1 120 = shoulder to 120°.

הפקודה כרגעcommand now: 3 40

📄 code/level3_arm_manual.ino📄 code/level3_arm_manual.ino

מפגש 7Session 7

פרק ב' 🎬
שהזרוע תעשה משהו
Part B 🎬
Make the arm do something

הזרוע בנויה וכל מפרק נשמע לנו. עכשיו: תנועה חלקה, דרכים נוחות "להניח" תנוחה, ולשמור רצף תנוחות שהזרוע תשחזר לבד — הרם-והנח. The arm is built and every joint obeys. Now: smooth motion, easy ways to "pose" it, and saving a sequence of poses the arm replays on its own — pick-and-place.

תזכורת משיעור 3: מפרידים בין "מה לעשות" ל"איך הפקודה מגיעה". חוזר גם כאן.Recall from Lesson 3: separate "what to do" from "how the command arrives". It returns here too.

16תנועה חלקה במקום קפיצהSmooth motion instead of a jump

write(150) אומר לסרוו "לך ל-150° עכשיו" — והוא קופץ לשם הכי מהר שהוא יכול. זה מכביד על גלגלי השיניים, מושך זרם גדול, ונראה קופצני. write(150) tells the servo "go to 150° now" — and it snaps there as fast as it can. That stresses the gears, pulls a big current, and looks jerky.

במקום זה: מתקדמים מעלה-מעלה בצעד קטן, עם delay זעיר בין צעד לצעד. זה "מחליק" את התנועה. Instead: step one degree at a time with a tiny delay between steps. That "glides".

void moveTo(int target, int stepDelay){
  while (current != target){
    current += (target > current) ? 1 : -1;
    joint.write(current);
    delay(stepDelay); // bigger = slower
  }
}

📄 code/level4_smooth_move.ino📄 code/level4_smooth_move.ino

אותה תנועה — פעם בקפיצה, פעם חלק:Same move — once as a jump, once smooth:

17"שלט לימוד": פוטנציומטריםA "teach pendant": potentiometers

הדרך הכי טבעית למצוא תנוחה טובה — ביד. פוטנציומטר אחד לכל מפרק: מסובבים כפתור, המפרק עוקב. ממש כמו בשיעור 5, ה-map() ממיר 0–1023 ל-0–180. The most natural way to find a good pose — by feel. One pot per joint: turn a knob, the joint follows. Just like Lesson 5, map() converts 0–1023 to 0–180.

int raw   = analogRead(A0);   // 0..1023
int angle = map(raw, 0,1023, 0,180);
servo.write(angle);
  • 4 פוטנציומטרים על A0–A34 pots on A0–A3
  • הקוד גם מדפיס את הזוויות — רשמו תנוחות יפות למפגש הבאThe code also prints the angles — note down nice poses for the next step
זהו "teach pendant" אמיתי של רובוטים תעשייתיים — מניחים את הזרוע ידנית ומלמדים אותה תנוחות.This is a real industrial-robot "teach pendant" — you hand-pose the arm to teach it positions.

למסלול המתקדם 🚀For the advanced track 🚀

מי שסיים את הבנייה ואת השליטה הידנית — בונה את ה-pendant, מוצא 4–6 תנוחות ל"הרם-והנח", ורושם אותן. הן יהיו ה"הקלטה" בשקופית הבאה. If you've finished the build and manual control — wire the pendant, find 4–6 poses for a pick-and-place, and write them down. They become the "recording" on the next slide.

📄 code/bonus_pot_pendant.ino📄 code/bonus_pot_pendant.ino

18הקלטה והשמעה = הרם-והנחRecord & replay = pick-and-place

תנוחה = הזוויות של כל 4 המפרקים ברגע אחד: {base, shoulder, elbow, gripper}. שומרים כמה תנוחות במערך, והזרוע עוברת ביניהן בחלקות — וזה הרם-והנח. A pose = the angles of all 4 joints at one moment: {base, shoulder, elbow, gripper}. Store several poses in an array and the arm glides between them — that's pick-and-place.

int POSES[][4] = {
  { 90, 90, 90, 20}, // home, open
  { 90, 60, 40, 20}, // reach down
  { 90, 60, 40, 80}, // grab
  { 90, 90, 90, 80}, // lift
  {160, 90, 90, 80}, // rotate
  {160, 60, 40, 20}, // lower & release
};

📄 code/level5_record_play.ino📄 code/level5_record_play.ino

19שלט לזרוע — מהטלפון או הדפדפןA remote for the arm — phone or browser

הקסם משיעור 3 חוזר: פונקציות התנועה נשארות אותו דבר — רק מקור הפקודה מתחלף. אותה פקודת "<מפרק> <זווית>", עכשיו דרך Bluetooth. The Lesson-3 magic returns: the motion code stays the same — only the command's source changes. The same "<joint> <angle>", now over Bluetooth.

  • מודול HC-05 על הזרוע (TXD→D10, RXD←D11 דרך מפל מתח)An HC-05 on the arm (TXD→D10, RXD←D11 via a divider)
  • שולחים תנוחות מטרמינל Bluetooth בטלפוןSend poses from a phone Bluetooth terminal
  • או — ממרכז השליטה בדפדפן שבניתם בשיעור 5 (Web Serial)Or — from the browser command center you built in Lesson 5 (Web Serial)
זה בדיוק ה-DNA של הקורס: "גוף" אחד, כמה "מוחות". הזרוע לא יודעת אם הפקודה באה מ-USB, מטלפון או מדפדפן.This is the course's DNA: one "body", many "brains". The arm doesn't know if the command came from USB, a phone, or a browser.

אותה פקודה, מקור אחרSame command, different source

// over USB (Lesson 6, level 3):
int j = Serial.parseInt();
int a = Serial.parseInt();
servos[j].write(a);

// over Bluetooth - only the source changed:
int j = bt.parseInt();
int a = bt.parseInt();
servos[j].write(a);

📄 code/bonus_bt_arm.ino📄 code/bonus_bt_arm.ino

20בטיחות ותקלות נפוצותSafety & common gotchas

בטיחותSafety

  • 🤏 נקודות צביטה — אצבעות הרחק מהמפרקים ומהתפסן בזמן תנועה🤏 Pinch points — keep fingers clear of joints and the gripper while it moves
  • ✋ אל תסובבו מפרק ביד כשיש כוח✋ Don't turn a joint by hand while powered
  • 🔒 הגבילו בקוד: constrain() כדי שמפרק לא יתנגש בעצמו או ישבור משהו🔒 Limit in code: constrain() so a joint can't hit itself or break something
  • ⚡ ודאו שהסרוו בטווח המתח (4.8–6V) — מתח גבוה מדי שורף⚡ Keep the servo in its voltage range (4.8–6V) — too high burns it out

תקלות נפוצותCommon gotchas

תופעהSymptomסיבה סבירהLikely cause
הארדואינו מתאתחלArduino resetsנפילת מתח — צריך ספק חזק יותרbrown-out — need a stronger supply
סרוו רועד/משתגעServo jitters/wildאין גראונד משותףno common ground
זז הפוך / חצי טווחMoves backward / half rangeלא אופס ל-90° לפני ההרכבהnot centered to 90° before assembly
חלש / "מוותר"Weak / "gives up"עומס רחוק מדי מהציר (מומנט)load too far from shaft (torque)

21סיכום ואתגריםSummary & challenges

הרעיון האחדThe one idea

סרוו הוא מנוע שיודע איפה הוא ומחזיק זווית. זרוע היא בסך הכול כמה סרוו מתואמים — ותנוחה היא רשימת זוויות. כל השאר זה כוח נכון, גראונד משותף, ותיאום בקוד. A servo is a motor that knows where it is and holds an angle. An arm is just a few coordinated servos — and a pose is a list of angles. The rest is proper power, a common ground, and coordination in code.

מה עשינוWhat we did

  • הבנו סרוו לעומק (זווית, PWM, לולאת משוב, מומנט)Understood servos deeply (angle, PWM, feedback loop, torque)
  • הזנו 4 סרוו נכון ובנינו זרוע 4-DOFPowered 4 servos correctly and built a 4-DOF arm
  • משליטה במפרק → תנועה חלקה → הרם-והנח → שלטFrom joint control → smooth motion → pick-and-place → a remote

אתגריםChallenges

  • הוסיפו כפתור "REC": לחיצה שומרת את התנוחה הנוכחית מה-pendant למערךAdd a "REC" button: a press saves the current pendant pose into the array
  • גרמו לזרוע לצייר ריבוע/עיגול באוויר (רצף תנוחות)Make the arm draw a square/circle in the air (a pose sequence)
  • חיישן + זרוע: HC-SR04 מזהה חפץ → הזרוע אוספת אותו לבדSensor + arm: an HC-SR04 detects an object → the arm picks it up on its own

💻 כל קבצי הקוד של השיעור — הורדה והסברAll of this lesson's code — download & walkthrough

כל הכבוד — בניתם רובוט אמיתי! 🦾 נתראה בשיעור הבא 👋Well done — you built a real robot! 🦾 See you next lesson 👋