Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ATX2.h>
- #define TIME 10
- signed int pos1=80, pos2=60, pos3=100, pos4=85; // กำหนดค่าเริ่มต้นตำแหน่งแกนมุมของเซอร์โวมอเตอร์ของแต่ละตัว
- void setup() {
- OK();
- delay(3000);
- FourServoSet(pos1, pos2, pos3, pos4);
- delay(1000);
- }
- void loop() {
- OK();
- delay(1500);
- Arm1TurnRight();
- delay(1500);
- Arm4Open();
- delay(1500);
- Arm3StretchedOut();
- delay(1500);
- Arm4Close();
- delay(1500);
- Arm3DrawBack();
- delay(1500);
- Arm2Up();
- delay(1500);
- Arm1TurnLeft();
- delay(1500);
- Arm2Down();
- delay(1500);
- Arm3StretchedOut();
- delay(1500);
- Arm4Open();
- delay(1500);
- Arm3DrawBack();
- delay(1500);
- }
- void FourServoSet(signed int sv0_angle, signed int sv1_angle, signed int sv2_angle, signed int sv3_angle)
- {
- servo(1, sv0_angle);
- servo(2, sv1_angle);
- servo(3, sv2_angle);
- servo(4, sv3_angle);
- }
- void Arm1TurnLeft()
- {
- for(pos1;pos1<115;pos1++)
- {
- servo(1, pos1);
- delay(TIME);
- }
- }
- void Arm1TurnRight()
- {
- for(pos1;pos1>45;pos1--)
- {
- servo(1, pos1);
- delay(TIME);
- }
- }
- void Arm2Up()
- {
- for(pos2;pos2>30;pos2--)
- {
- servo(2, pos2);
- delay(TIME);
- }
- }
- void Arm2Down()
- {
- for(pos2;pos2<60;pos2++)
- {
- servo(2, pos2);
- delay(TIME);
- }
- }
- void Arm3StretchedOut()
- {
- for(pos3;pos3>30;pos3--)
- {
- servo(3, pos3);
- delay(TIME);
- }
- }
- void Arm3DrawBack()
- {
- for(pos3;pos3<100;pos3++)
- {
- servo(3, pos3);
- delay(TIME);
- }
- }
- void Arm4Close()
- {
- for(pos4;pos4>85;pos4--)
- {
- servo(4, pos4);
- delay(TIME);
- }
- }
- void Arm4Open()
- {
- for(pos4;pos4<165;pos4++)
- {
- servo(4, pos4);
- delay(TIME);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement