• Complain

Elif Avcu - The Best Fifty Project With The Arduino

Here you can read online Elif Avcu - The Best Fifty Project With The Arduino full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    The Best Fifty Project With The Arduino
  • Author:
  • Genre:
  • Year:
    2018
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

The Best Fifty Project With The Arduino: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "The Best Fifty Project With The Arduino" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Arduino with the best fifty projects in this book.Book designed for designers.High school education is also used as a textbook

Elif Avcu: author's other books


Who wrote The Best Fifty Project With The Arduino? Find out the surname, the name of the author of the book and a list of all author's works by series.

The Best Fifty Project With The Arduino — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "The Best Fifty Project With The Arduino" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make

THE BEST FIFTY PROJECT WITH THE ARDUiNO 1- ) ARDUINO CAR PARK SENSOR PROJECT 2-) ARDUINO ANDROID CONTROLLED ORIGINAL ROBOT CONSTRUCTION 3-) ARDUINO AUTOMATIC FISH FEEDING MACHINE WOOD PROJECT 4-) ARDUINO EMG SENSOR PROSTHESIS ARM PROJECT 5-) ARDUINO ULTRASONIC RADAR PROJECT 6-) SERVO MOTOR CONTROL WITH ARDUINO IR INFRARED CONTROL 7-) DIGITAL METER CONSTRUCTION WITH ARDUINO 8-) ARDUINO SHAKING TEA MACHINE 9)ARDUINO DC MOTOR SPEED DIMENSION 10) REMOTE CONTROL APPLICATION WITH ARDUINO AND NRF24L01 11) 3D ROBOT PROJECT WITH BOB LOCATED WITH ARDUINO 12) ARDUNO FUZZY LOGIC TEMPERATURE MOISTURE PROJECT 13) DRAWING ROBOT CAR 14) HOVERBOARD CONSTRUCTION WITH ARDUNO 15) ROBOT ARM WITH ARDUNO LASER CUTTING 16) BOMB DISPOSAL ROBOT PROJECT WITH ARDUiNO 17) ARDUNO SPIDER ROBOT CONSTRUCTION 18) HUMAN ROBOT CONSTRUCTION WITH ARDUiNO 19) ARDUINO OLLIE ROBOT CONSTRUCTION 20) ROBOT MAKING FAST LINE WITH ARDUNO 21) ROBOT PRODUCTION TREATED WITH ARDUiNO 22) ROBOT CONSTRUCTION PROJECT WITH ARDUNO 23) TANK PRODUCTION WITH ARDUiNO 24) SUMO ROBOT PROJECT WITH ARDUiNO 25) ROBOT CONTROL PROJECT WITH ARDUiNO TELEVISION CONTROL 26) ARDUiNO ANDROID CONTROLLED RC CAR PROJECT 27) ARDUINO WITH LCD DISPLAY HUMIDITY AND TEMPERATURE PROJECT 28) ARDUNO PLAYING A AUDIO SOUND FROM SD CARD 29) 5 AXIS ROBOT HANDLE CHECKED BY HAND MOTION 30) ULTRASONIC MAXIMUM RADAR PROJECT FOR VISUALLY IMPAIRED WITH ARDUNO 31) ROBOT CONSTRUCTION WITH ARDUiNO AND MATLAB 32) ROBOTIC HAND MADE OF FLEX SENSOR WITH WIRELESS CONTROL WITH ARDUNO 33) ARDUNO 3 AXIS CNC CONSTRUCTION 34) ARDUNO PORTABLE GAS DETECTOR 35) ARDUNO ULTRASONIC SENSOR WITH LCD DISPLAY MEASUREMENT 36) ARDUNO TRACKED TANK ROBOT 37) PIANO BUILDING WITH ARDUINO 38) DIGITAL COMPASS CONSTRUCTION WITH ARDUINO 39) USE OF ARDUNO KEYPAD 40) ARDUINO FLAME SENSOR APPLICATION 41) ARDUNO WIFI WEATHER STATION 42) ARDUINO COLOR SENSOR APPLICATION 43) ARDUNO Infrared (IR) SENSOR APPLICATION 44) ARDUNO HEIGHT DIMENSIONS PROJECT 45) MOBILE PHONE CONSTRUCTION PROJECT WITH ARDUNO 46) DC MOTOR DRIVING WITH ARDUINO PWM 47) ARDUNO GPS MODULE LOCATION 48) RGB LED CONTROL WITH ARDUINO CONTROL 49) ARDUiNO RFID-RC522 DOOR LOCK PROJECT 50) SERVO ENGINE CONTROL WITH ARDUINO JOYSTIC 1- ) ARDUINO CAR PARK SENSOR PROJECT Ill tell you a fun project that you can do on a low budget A small copy of - photo 1 I'll tell you a fun project that you can do on a low budget. A small copy of your parking sensor we have seen in our life. First I will tell you what Arduino is doing. We can easily program with Arduino libraries. Using the signals from the sensors, we can design robots and systems that interact with the environment. Arduino has various cards and modules designed to provide solutions to different needs.

We can develop your projects using these cards and modules. NECESSARY MATERIALS: ARDUINO 4 LEDs 5 PCS 220 OHM RESISTANCE 1 PIECE BUZZER BREAD BOARD QUANTITY JUMPER CABLE Scheme showing the links of our Project Deviation Codes const int triggerpin 12 const int echopin 13 - photo 2 Deviation Codes: const int trigger_pin = 12; const int echo_pin = 13; const int aled = 2 ; const int bled = 3;. const int cled = 4; const int dled = 5; const int buzzer = 6; int sure ; int mesafe ; void setup() { pinMode(aled , OUTPUT); pinMode(bled , OUTPUT); pinMode(cled , OUTPUT); pinMode(dled , OUTPUT); pinMode(buzzer , OUTPUT pinMode(trigger_pin , OUTPUT); pinMode(echo_pin , INPUT); } void loop() { digitalWrite(trigger_pin , HIGH); delayMicroseconds(1000); // digitalWrite(trigger_pin , LOW); sure = pulseIn(echo_pin , HIGH); mesafe = (sure / 2) / 29.1; if (mesafe <= 10) { digitalWrite(aled , HIGH); digitalWrite(bled , HIGH); digitalWrite(cled , HIGH); digitalWrite(dled , HIGH); digitalWrite(buzzer , HIGH); delay(250); digitalWrite(buzzer , LOW); } else if (mesafe <= 25) { digitalWrite(aled , LOW); digitalWrite(bled , HIGH); digitalWrite(cled , HIGH); digitalWrite(dled , HIGH); digitalWrite(buzzer , HIGH); delay(500); digitalWrite(buzzer , LOW); } else if ( mesafe <= 50) { digitalWrite(aled , LOW); digitalWrite(bled , LOW);. digitalWrite(cled , HIGH); digitalWrite(dled , HIGH); digitalWrite(buzzer , HIGH); delay(750); digitalWrite(buzzer , LOW); } else { digitalWrite(aled , LOW); digitalWrite(bled , LOW); digitalWrite(cled , LOW); digitalWrite(dled , HIGH); } } 2-) ARDUINO ANDROID CONTROLLED ORIGINAL ROBOT CONSTRUCTION NECESSARY MATERIALS 12 Pieces sg90 servo motor Arduino Uno Arduino - photo 3 NECESSARY MATERIALS: 12 Pieces sg90 servo motor Arduino Uno Arduino ProtoShield HC-05 or HC-06 bluetooth module 3D Parts Power source Download link for robotic body: http://www.thingiverse.com/thing:1009659 http://www.instructables.com/id/DIY-Spider-RobotQuad-robot-Quadruped/step1/Test-the-main-board/ Parts Required:

  • 1 x body_d.stl
  • 1 x body_u.stl
  • 2 x coxa_l.stl
  • 2 x coxa_r.stl
  • 2 x tibia_l.stl
  • 2 x tibia_r.stl
  • 4 x femur_1.stl
  • 8 x s_hold.stl
Now all the plastic parts are going to be assembled after the punch. The first thing you need to do is to insert the servo motors into the places where you need to enter, remove the 4 screws under the servos and lift the lid so as not to damage the servo cable. Screw in the cover again after inserting the servo into place.

NOTE-2: Do not screw the upper plastic parts of servo motors. Observe the sources I supply when replacing the servomotors and pay attention to what direction the motors are facing. The motors need to be connected according to the leg order. The engines are numbered according to the leg order. At the same time, the Arduino code records which motor should be connected to which pine. There is a setting code for setting the angles of the motors after assembly is - photo 4 There is a setting code for setting the angles of the motors after assembly is finished.

The upper plastic parts of the servos need to be screwed after this test code is loaded. Try to make the positions and alignments of the parts as symmetrical as possible, and then screw the upper plastic part of the servo motors, as shown in the source I should pay attention to here. Setting Code of Servos: http://www.instructables.com/id/DIY-Spider-RobotQuad-robot-Quadruped/step11/Locate-the-initial-position-for-legs/ If the servos are not screwed in after the setting code the process is - photo 5 If the servos are not screwed in after the setting code, the process is complete. You can now download the actual code. Arduino Code: http://www.instructables.com/id/DIY-Spider-RobotQuad-robot-Quadruped/step13/It-is-showtime/ /* Includes ------------------------------------------------------------------*/ #include //to define and control servos #include //to set a timer to manage all servos /* Servos --------------------------------------------------------------------*/ //define 12 servos for 4 legs Servo servo[4][3]; //define servos' ports cons t in t servo_pin[4][3] = { {2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {11, 12, 13} }; /* Size of the robot ---------------------------------------------------------*/ cons t floa t length_a = 55; cons t floa t length_b = 77.5; cons t floa t length_c = 27.5; cons t floa t length_side = 71; cons t floa t z_absolute = -28; /* Constants for movement ----------------------------------------------------*/ cons t floa t z_default = -50, z_up = -30, z_boot = z_absolute; cons t floa t x_default = 62, x_offset = 0; cons t floa t y_start = 0, y_step = 40; /* variables for movement ----------------------------------------------------*/ volatil e floa t site_now[4][3]; //real-time coordinates of the end of each leg volatil e floa t site_expect[4][3]; //expected coordinates of the end of each leg floa t temp_speed[4][3]; //each axis' speed, needs to be recalculated before each movement floa t move_speed; //movement speed floa t speed_multiple = 1; //movement speed multiple cons t floa t spot_turn_speed = 4; cons t floa t leg_move_speed = 8; cons t floa t body_move_speed = 3; cons t floa t stand_seat_speed = 1; volatil e in t rest_counter; //+1/0.02s, for automatic rest //functions' parameter cons t floa t KEEP = 255; //define PI for calculation cons t floa t pi = 3.1415926; /* Constants for turn --------------------------------------------------------*/ //temp length cons t floa t temp_a = sqrt(pow(2 * x_default + length_side, 2) + pow(y_step, 2)); cons t floa t temp_b = 2 * (y_start + y_step) + length_side; cons t floa t temp_c = sqrt(pow(2 * x_default + length_side, 2) + pow(2 * y_start + y_step + length_side, 2)); cons t floa t temp_alpha = acos((pow(temp_a, 2) + pow(temp_b, 2) - pow(temp_c, 2)) / 2 / temp_a / temp_b); //site for turn cons t floa t turn_x1 = (temp_a - length_side) / 2; cons t floa t turn_y1 = y_start + y_step / 2; cons t floa t turn_x0 = turn_x1 - temp_b * cos(temp_alpha); cons t floa t turn_y0 = temp_b * sin(temp_alpha) - turn_y1 - length_side; /* ---------------------------------------------------------------------------*/ /* - setup function ---------------------------------------------------------------------------*/ voi d setup() { //start serial for debug Serial.begin(115200); Serial.println("Robot starts initialization"); //initialize default parameter set_site(0, x_default - x_offset, y_start + y_step, z_boot); set_site(1, x_default - x_offset, y_start + y_step, z_boot); set_site(2, x_default + x_offset, y_start, z_boot); set_site(3, x_default + x_offset, y_start, z_boot); fo r (in t i = 0; i < 4; i++) { fo r (in t j = 0; j < 3; j++) { site_now[i][j] = site_expect[i][j]; } } //start servo service FlexiTimer2::set(20, servo_service); FlexiTimer2::start(); Serial.println("Servo service started"); //initialize servos servo_attach(); Serial.println("Servos initialized"); Serial.println("Robot initialization Complete"); } voi d servo_attach(void) { fo r (in t i = 0; i < 4; i++) { fo r (in t j = 0; j < 3; j++) { servo[i][j].attach(servo_pin[i][j]); delay(100); } } } voi d servo_detach(void) { fo r (in t i = 0; i < 4; i++) { fo r (in t j = 0; j < 3; j++) { servo[i][j].detach(); delay(100); } } } /* - loop function ---------------------------------------------------------------------------*/ voi d loop() { Serial.println("Stand"); stand(); delay(2000); Serial.println("Step forward"); step_forward(5); delay(2000); Serial.println("Step back"); step_back(5); delay(2000); Serial.println("Turn left"); turn_left(5); delay(2000); Serial.println("Turn right"); turn_right(5); delay(2000); Serial.println("Hand wave"); hand_wave(3); delay(2000); Serial.println("Hand wave"); hand_shake(3); delay(2000); Serial.println("Sit"); sit(); delay(5000); } /* - sit - blocking function ---------------------------------------------------------------------------*/ voi d sit(void) { move_speed = stand_seat_speed; fo r (in t leg = 0; leg < 4; leg++) { set_site(leg, KEEP, KEEP, z_boot); } wait_all_reach(); } /* - stand - blocking function ---------------------------------------------------------------------------*/ voi d stand(void) { move_speed = stand_seat_speed; fo r (in t leg = 0; leg < 4; leg++) { set_site(leg, KEEP, KEEP, z_default); } wait_all_reach(); } /* - spot turn to left - blocking function - parameter step steps wanted to turn ---------------------------------------------------------------------------* / voi d turn_left(unsigned in t step) { move_speed = spot_turn_speed; whil e (step-- > 0) { i f (site_now[3][1] == y_start) { //leg 3&1 move set_site(3, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(0, turn_x1 - x_offset, turn_y1, z_default); set_site(1, turn_x0 - x_offset, turn_y0, z_default); set_site(2, turn_x1 + x_offset, turn_y1, z_default); set_site(3, turn_x0 + x_offset, turn_y0, z_up); wait_all_reach(); set_site(3, turn_x0 + x_offset, turn_y0, z_default); wait_all_reach(); set_site(0, turn_x1 + x_offset, turn_y1, z_default); set_site(1, turn_x0 + x_offset, turn_y0, z_default); set_site(2, turn_x1 - x_offset, turn_y1, z_default); set_site(3, turn_x0 - x_offset, turn_y0, z_default); wait_all_reach(); set_site(1, turn_x0 + x_offset, turn_y0, z_up); wait_all_reach(); set_site(0, x_default + x_offset, y_start, z_default); set_site(1, x_default + x_offset, y_start, z_up); set_site(2, x_default - x_offset, y_start + y_step, z_default); set_site(3, x_default - x_offset, y_start + y_step, z_default); wait_all_reach(); set_site(1, x_default + x_offset, y_start, z_default); wait_all_reach(); } else { //leg 0&2 move set_site(0, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(0, turn_x0 + x_offset, turn_y0, z_up); set_site(1, turn_x1 + x_offset, turn_y1, z_default); set_site(2, turn_x0 - x_offset, turn_y0, z_default); set_site(3, turn_x1 - x_offset, turn_y1, z_default); wait_all_reach(); set_site(0, turn_x0 + x_offset, turn_y0, z_default); wait_all_reach(); set_site(0, turn_x0 - x_offset, turn_y0, z_default); set_site(1, turn_x1 - x_offset, turn_y1, z_default); set_site(2, turn_x0 + x_offset, turn_y0, z_default); set_site(3, turn_x1 + x_offset, turn_y1, z_default); wait_all_reach(); set_site(2, turn_x0 + x_offset, turn_y0, z_up); wait_all_reach(); set_site(0, x_default - x_offset, y_start + y_step, z_default); set_site(1, x_default - x_offset, y_start + y_step, z_default); set_site(2, x_default + x_offset, y_start, z_up); set_site(3, x_default + x_offset, y_start, z_default); wait_all_reach(); set_site(2, x_default + x_offset, y_start, z_default); wait_all_reach(); } } } /* - spot turn to right - blocking function - parameter step steps wanted to turn ---------------------------------------------------------------------------*/ voi d turn_right(unsigned in t step) { move_speed = spot_turn_speed; whil e (step-- > 0) { i f (site_now[2][1] == y_start) { //leg 2&0 move set_site(2, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(0, turn_x0 - x_offset, turn_y0, z_default); set_site(1, turn_x1 - x_offset, turn_y1, z_default); set_site(2, turn_x0 + x_offset, turn_y0, z_up); set_site(3, turn_x1 + x_offset, turn_y1, z_default); wait_all_reach(); set_site(2, turn_x0 + x_offset, turn_y0, z_default); wait_all_reach(); set_site(0, turn_x0 + x_offset, turn_y0, z_default); set_site(1, turn_x1 + x_offset, turn_y1, z_default); set_site(2, turn_x0 - x_offset, turn_y0, z_default); set_site(3, turn_x1 - x_offset, turn_y1, z_default); wait_all_reach(); set_site(0, turn_x0 + x_offset, turn_y0, z_up); wait_all_reach(); set_site(0, x_default + x_offset, y_start, z_up); set_site(1, x_default + x_offset, y_start, z_default); set_site(2, x_default - x_offset, y_start + y_step, z_default); set_site(3, x_default - x_offset, y_start + y_step, z_default); wait_all_reach(); set_site(0, x_default + x_offset, y_start, z_default); wait_all_reach(); } else { //leg 1&3 move set_site(1, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(0, turn_x1 + x_offset, turn_y1, z_default); set_site(1, turn_x0 + x_offset, turn_y0, z_up); set_site(2, turn_x1 - x_offset, turn_y1, z_default); set_site(3, turn_x0 - x_offset, turn_y0, z_default); wait_all_reach(); set_site(1, turn_x0 + x_offset, turn_y0, z_default); wait_all_reach(); set_site(0, turn_x1 - x_offset, turn_y1, z_default); set_site(1, turn_x0 - x_offset, turn_y0, z_default); set_site(2, turn_x1 + x_offset, turn_y1, z_default); set_site(3, turn_x0 + x_offset, turn_y0, z_default); wait_all_reach(); set_site(3, turn_x0 + x_offset, turn_y0, z_up); wait_all_reach(); set_site(0, x_default - x_offset, y_start + y_step, z_default); set_site(1, x_default - x_offset, y_start + y_step, z_default); set_site(2, x_default + x_offset, y_start, z_default); set_site(3, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(3, x_default + x_offset, y_start, z_default); wait_all_reach(); } } } /* - go forward - blocking function - parameter step steps wanted to go ---------------------------------------------------------------------------*/ voi d step_forward(unsigned in t step) { move_speed = leg_move_speed; whil e (step-- > 0) { i f (site_now[2][1] == y_start) { //leg 2&1 move set_site(2, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(2, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(2, x_default + x_offset, y_start + 2 * y_step, z_default); wait_all_reach(); move_speed = body_move_speed; set_site(0, x_default + x_offset, y_start, z_default); set_site(1, x_default + x_offset, y_start + 2 * y_step, z_default); set_site(2, x_default - x_offset, y_start + y_step, z_default); set_site(3, x_default - x_offset, y_start + y_step, z_default); wait_all_reach(); move_speed = leg_move_speed; set_site(1, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(1, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(1, x_default + x_offset, y_start, z_default); wait_all_reach(); } else { //leg 0&3 move set_site(0, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(0, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(0, x_default + x_offset, y_start + 2 * y_step, z_default); wait_all_reach(); move_speed = body_move_speed; set_site(0, x_default - x_offset, y_start + y_step, z_default); set_site(1, x_default - x_offset, y_start + y_step, z_default); set_site(2, x_default + x_offset, y_start, z_default); set_site(3, x_default + x_offset, y_start + 2 * y_step, z_default); wait_all_reach(); move_speed = leg_move_speed; set_site(3, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(3, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(3, x_default + x_offset, y_start, z_default); wait_all_reach(); } } } /* - go back - blocking function - parameter step steps wanted to go ---------------------------------------------------------------------------*/ voi d step_back(unsigned in t step) { move_speed = leg_move_speed; whil e (step-- > 0) { i f (site_now[3][1] == y_start) { //leg 3&0 move set_site(3, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(3, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(3, x_default + x_offset, y_start + 2 * y_step, z_default); wait_all_reach(); move_speed = body_move_speed; set_site(0, x_default + x_offset, y_start + 2 * y_step, z_default); set_site(1, x_default + x_offset, y_start, z_default); set_site(2, x_default - x_offset, y_start + y_step, z_default); set_site(3, x_default - x_offset, y_start + y_step, z_default); wait_all_reach(); move_speed = leg_move_speed; set_site(0, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(0, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(0, x_default + x_offset, y_start, z_default); wait_all_reach(); } else { //leg 1&2 move set_site(1, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(1, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(1, x_default + x_offset, y_start + 2 * y_step, z_default); wait_all_reach(); move_speed = body_move_speed; set_site(0, x_default - x_offset, y_start + y_step, z_default); set_site(1, x_default - x_offset, y_start + y_step, z_default); set_site(2, x_default + x_offset, y_start + 2 * y_step, z_default); set_site(3, x_default + x_offset, y_start, z_default); wait_all_reach(); move_speed = leg_move_speed; set_site(2, x_default + x_offset, y_start + 2 * y_step, z_up); wait_all_reach(); set_site(2, x_default + x_offset, y_start, z_up); wait_all_reach(); set_site(2, x_default + x_offset, y_start, z_default); wait_all_reach(); } } } // add by RegisHsu voi d body_left(in t i) { set_site(0, site_now[0][0] + i, KEEP, KEEP); set_site(1, site_now[1][0] + i, KEEP, KEEP); set_site(2, site_now[2][0] - i, KEEP, KEEP); set_site(3, site_now[3][0] - i, KEEP, KEEP); wait_all_reach(); } voi d body_right(in t i) { set_site(0, site_now[0][0] - i, KEEP, KEEP); set_site(1, site_now[1][0] - i, KEEP, KEEP); set_site(2, site_now[2][0] + i, KEEP, KEEP); set_site(3, site_now[3][0] + i, KEEP, KEEP); wait_all_reach(); } voi d hand_wave(in t i) { floa t x_tmp; floa t y_tmp; floa t z_tmp; move_speed = 1; i f (site_now[3][1] == y_start) { body_right(15); x_tmp = site_now[2][0]; y_tmp = site_now[2][1]; z_tmp = site_now[2][2]; move_speed = body_move_speed; fo r (in t j = 0; j < i; j++) { set_site(2, turn_x1, turn_y1, 50); wait_all_reach(); set_site(2, turn_x0, turn_y0, 50); wait_all_reach(); } set_site(2, x_tmp, y_tmp, z_tmp); wait_all_reach(); move_speed = 1; body_left(15); } else { body_left(15); x_tmp = site_now[0][0]; y_tmp = site_now[0][1]; z_tmp = site_now[0][2]; move_speed = body_move_speed; fo r (in t j = 0; j < i; j++) { set_site(0, turn_x1, turn_y1, 50); wait_all_reach(); set_site(0, turn_x0, turn_y0, 50); wait_all_reach(); } set_site(0, x_tmp, y_tmp, z_tmp); wait_all_reach(); move_speed = 1; body_right(15); } } voi d hand_shake(in t i) { floa t x_tmp; floa t y_tmp; floa t z_tmp; move_speed = 1; i f (site_now[3][1] == y_start) { body_right(15); x_tmp = site_now[2][0]; y_tmp = site_now[2][1]; z_tmp = site_now[2][2]; move_speed = body_move_speed; fo r (in t j = 0; j < i; j++) { set_site(2, x_default - 30, y_start + 2 * y_step, 55); wait_all_reach(); set_site(2, x_default - 30, y_start + 2 * y_step, 10); wait_all_reach(); } set_site(2, x_tmp, y_tmp, z_tmp); wait_all_reach(); move_speed = 1; body_left(15); } else { body_left(15); x_tmp = site_now[0][0]; y_tmp = site_now[0][1]; z_tmp = site_now[0][2]; move_speed = body_move_speed; fo r (in t j = 0; j < i; j++) { set_site(0, x_default - 30, y_start + 2 * y_step, 55); wait_all_reach(); set_site(0, x_default - 30, y_start + 2 * y_step, 10); wait_all_reach(); } set_site(0, x_tmp, y_tmp, z_tmp); wait_all_reach(); move_speed = 1; body_right(15); } } /* - microservos service /timer interrupt function/50Hz - when set site expected,this function move the end point to it in a straight line - temp_speed[4][3] should be set before set expect site,it make sure the end point move in a straight line,and decide move speed. ---------------------------------------------------------------------------*/ voi d servo_service(void) { sei(); stati c floa t alpha, beta, gamma; fo r (in t i = 0; i < 4; i++) { fo r (in t j = 0; j < 3; j++) { i f (abs(site_now[i][j] - site_expect[i][j]) >= abs(temp_speed[i][j])) site_now[i][j] += temp_speed[i][j]; else site_now[i][j] = site_expect[i][j]; } cartesian_to_polar(alpha, beta, gamma, site_now[i][0], site_now[i][1], site_now[i][2]); polar_to_servo(i, alpha, beta, gamma); } rest_counter++; } /* - set one of end points' expect site - this founction will set temp_speed[4][3] at same time - non - blocking function ---------------------------------------------------------------------------*/ voi d set_site(in t leg, floa t x, floa t y, floa t z) { floa t length_x = 0, length_y = 0, length_z = 0; i f (x != KEEP) length_x = x - site_now[leg][0]; i f (y != KEEP) length_y = y - site_now[leg][1]; i f (z != KEEP) length_z = z - site_now[leg][2]; floa t length = sqrt(pow(length_x, 2) + pow(length_y, 2) + pow(length_z, 2)); temp_speed[leg][0] = length_x / length * move_speed * speed_multiple; temp_speed[leg][1] = length_y / length * move_speed * speed_multiple; temp_speed[leg][2] = length_z / length * move_speed * speed_multiple; i f (x != KEEP) site_expect[leg][0] = x; i f (y != KEEP) site_expect[leg][1] = y; i f (z != KEEP) site_expect[leg][2] = z; } /* - wait one of end points move to expect site - blocking function ---------------------------------------------------------------------------*/ voi d wait_reach(in t leg) { whil e (1) i f (site_now[leg][0] == site_expect[leg][0]) i f (site_now[leg][1] == site_expect[leg][1]) i f (site_now[leg][2] == site_expect[leg][2]) break; } /* - wait all of end points move to expect site - blocking function ---------------------------------------------------------------------------*/ voi d wait_all_reach(void) { fo r (in t i = 0; i < 4; i++) wait_reach(i); } /* - trans site from cartesian to polar - mathematical model 2/2 ---------------------------------------------------------------------------* / voi d cartesian_to_polar(volatil e floa t &alpha, volatil e floa t &beta, volatil e floa t &gamma, volatil e floa t x, volatil e floa t y, volatil e floa t z) { //calculate w-z degree float v, w; w = (x >= 0 ? 1 : -1) * (sqrt(pow(x, 2) + pow(y, 2))); v = w - length_c; alpha = atan2(z, v) + acos((pow(length_a, 2) - pow(length_b, 2) + pow(v, 2) + pow(z, 2)) / 2 / length_a / sqrt(pow(v, 2) + pow(z, 2))); beta = acos((pow(length_a, 2) + pow(length_b, 2) - pow(v, 2) - pow(z, 2)) / 2 / length_a / length_b); //calculate x-y-z degree gamma = (w >= 0) ? atan2(y, x) : atan2(-y, -x); //trans degree pi->180 alpha = alpha / pi * 180; beta = beta / pi * 180; gamma = gamma / pi * 180; } /* - trans site from polar to microservos - mathematical model map to fact - the errors saved in eeprom will be add ---------------------------------------------------------------------------*/ voi d polar_to_servo(in t leg, floa t alpha, floa t beta, floa t gamma) { i f (leg == 0) { alpha = 90 - alpha; beta = beta; gamma += 90; } els e i f (leg == 1) { alpha += 90; beta = 180 - beta; gamma = 90 - gamma; } els e i f (leg == 2) { alpha += 90; beta = 180 - beta; gamma = 90 - gamma; } els e i f (leg == 3) { alpha = 90 - alpha; beta = beta; gamma += 90; } servo[leg][0].write(alpha); servo[leg][1].write(beta); servo[leg][2].write(gamma); } Bluetooth Connection: The pins of the bluetooth module are connected to the COM part on the sensor shield.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «The Best Fifty Project With The Arduino»

Look at similar books to The Best Fifty Project With The Arduino. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «The Best Fifty Project With The Arduino»

Discussion, reviews of the book The Best Fifty Project With The Arduino and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.