Difference between revisions of "Arduino 13 - nastavovanie serva"
(Created page with "<syntaxhighlight lang="C++"> #include <Servo.h> Servo motor; int uhol; void setup() { motor.attach(2); uhol = 90; motor.write(90); Serial.begin(9600); } void loop() {...") |
(No difference)
|
Revision as of 07:08, 31 July 2019
#include <Servo.h>
Servo motor;
int uhol;
void setup() {
motor.attach(2);
uhol = 90;
motor.write(90);
Serial.begin(9600);
}
void loop() {
if (Serial.available())
{
if (c == 'a')
if (uhol < 180) uhol++;
if (c == 'z')
if (uhol > 0) uhol--;
Serial.println(uhol);
motor.write(uhol);
}
}