F1lip: Rozdiel medzi revíziami

Zo stránky Robotický krúžok
Skočit na navigaci Skočit na vyhledávání
(Vytvorená stránka „== 11.10.24 == 600px <youtube>jhgjhgjg</youtube> <syntaxhighlight lang="c++"> #include <Servo.h> Servo tocna; Servo rameno; Servo laket; Servo ruka; int toc = 90, ram = 120, lak = 130, ruk = 60, k = 1; void setup() { ruka.attach(2); tocna.attach(3); rameno.attach(4); laket.attach(5); Serial.begin(115200); Serial.println("Servo controller"); tocna.write(toc); delay(500); rameno.write(ram); delay(500); laket.…“)
 
dBez shrnutí editace
Riadok 2: Riadok 2:




[[Image:robotic_arm.jpg|600px]]


 
<youtube>kl4e4lwIDNg</youtube>
[[image:robotic_arm.jpg|600px]]
 
 
<youtube>jhgjhgjg</youtube>


<syntaxhighlight lang="c++">
<syntaxhighlight lang="c++">

Verzia z 16:51, 11. október 2024

11.10.24

Robotic arm.jpg

#include <Servo.h>

Servo tocna;
Servo rameno;
Servo laket;
Servo ruka;

int toc = 90, ram = 120, lak = 130, ruk = 60, k = 1;

void setup() {
  ruka.attach(2);
  tocna.attach(3);
  rameno.attach(4);
  laket.attach(5);

  Serial.begin(115200);
  Serial.println("Servo controller");
  tocna.write(toc);
  delay(500);
  rameno.write(ram);
  delay(500);
  laket.write(ram);
  delay(500);
  ruka.write(ram);
  delay(500);
  Serial.println("Control movements with a-z, s-x, d-c, f-v");
}

void vypis()
{
  Serial.print("Tocna: ");
  Serial.print(toc);
  Serial.print(", rameno: ");
  Serial.print(ram);
  Serial.print(", laket: ");
  Serial.print(lak);
  Serial.print(", ruka: ");
  Serial.println(ruk);
}
void loop() {
  if (Serial.available())
  {
    char c = Serial.read();
    switch (c)
    {
      case 'a': toc+=k;
                if (toc > 180) toc = 180;
                tocna.write(toc);
                vypis();
                break;
      case 'z':  toc-=k;
                 if (toc < 0) toc = 0;
                 tocna.write(toc);
                 vypis();
                break;
      
      case 's': ram+=k;
                if (ram > 180) ram = 180;
                rameno.write(ram);
                vypis();
                break;
      case 'x': ram-=k;
                if (ram < 0) ram = 0;
                rameno.write(ram);
                vypis();
                break;

      case 'd': lak+=k;
                if (lak > 180) lak = 180;
                laket.write(lak);
                vypis();
                break;
      case 'c': lak-=k;
                if (lak < 0) lak = 0;
                laket.write(lak);
                vypis();
                break;

      case 'f': ruk+=k;
                if (ruk > 180) ruk = 180;
                ruka.write(ruk);
                vypis();
                break;
      case 'v': ruk-=k;
                if (ruk < 0) ruk = 0;
                ruka.write(ruk);
                vypis();
                break;
      case '+': k++;
                Serial.print("krok ");                
                Serial.println(k);
                break;
      case '-': k--;
                Serial.print("krok ");                
                Serial.println(k);
                break;
    }
  }
}

Ovladanie: