Dzien 7 - 17.10 -Piny Analogowe
- spr https://wiki.robisz.to/books/arduino
- Zadanie domowe z poprzednich zajec - swiatla i servo





Piny analogowe
- na Arduino ozn A , mamy ich 6. Piny analogowe - inputy




Zadanie 1





Mapowanie wartosci

- Zadanie



Ciekawostka 1: podlaczenie potencjometru - jesli podlaczymy odwrotnie terminal 1 i terminal 2 to zakres bedzie od tylu tzn 1023 do 0.
Ciekawostka 2: servo musi miec napiecie 5V.
- Zadanie: mapowanie i servomechanizm




- Zadanie: servo -4 ustawienia kąta obrotu. Wykorzystujemy variable :)


Command servo.attach
In the Arduino IDE, the command servo.attach(9, 500, 2500);
is used with the Servo library to control a servo motor. Let's break it down:
Breakdown of the command:
servo
: This is the Servo object that represents the servo motor. To use it, you first need to create a Servo object (e.g.,Servo servo;
).attach(9, 500, 2500)
: Theattach()
function is used to connect the Servo object to a specific pin and configure the range of pulse width values that control the servo's movement. The parameters in this function are:9
: This is the Arduino pin number to which the servo is connected. In this case, it's pin 9. You should connect the servo's signal wire (usually the yellow or white wire) to pin 9 on the Arduino board.500
: This is the minimum pulse width in microseconds. It defines the shortest pulse the servo will receive to move to its minimum position (usually 0 degrees). In this case, the minimum pulse width is set to 500 microseconds.2500
: This is the maximum pulse width in microseconds. It defines the longest pulse the servo will receive to move to its maximum position (usually 180 degrees). Here, the maximum pulse width is set to 2500 microseconds.
Default Servo Settings:
By default, most servo motors expect pulse widths between 1000 and 2000 microseconds, which correspond to the range of 0 to 180 degrees. However, some servos have a wider range of motion or require a different pulse width range for proper operation.
- The
500
and2500
values are typically used for servo motors that can rotate beyond the usual 180-degree range (e.g., 270-degree or 360-degree servos). These pulse widths correspond to a wider range of movement, so the servo may rotate a full 360 degrees or more, depending on the servo's specifications.