-
Archives
- July 2020
- June 2020
- December 2019
- August 2019
- April 2019
- March 2019
- February 2019
- July 2016
- June 2016
- April 2016
- January 2016
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- November 2013
-
Meta
Tag Archives: arduino
Making a USB Powered LED Bird Lamp
Drawings: Download svg file here Download code here Extra Info: LED strip used is ws2812b. Adafruit neopixel library ‘buttoncycler’ program lightly modified to work with a potentiometer. The peacock image was found via google images. link to the pinterest page … Continue reading
Posted in Arduino, how to, Ideas, Inkscape, laser cutter, Projects
Tagged arduino, laser cutter, video
2 Comments
PlantBot – The Plant Watering Robot
PlantBot – because watering plants is boring. Laser Cutter Plans: Here is a preview of what the plans look like: For laser cutting, click here to download an SVG file of the plans Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
#include <math.h> #include <Servo.h> Servo arm; Servo shoulder; Servo pull; //servo angle limits (abs degrees) #define S_MIN -60 #define S_MAX 60 #define A_MAX 170 #define A_MIN 0 #define P_OPEN -40 #define P_CLOSED 67 //xy_points of robot arm when over a plant box section int xy_points[16][2] = { {1,3}, {5,1}, {0,-12}, {0,-16}, {0,-3},{1,-5},{3,-10}, {3,-14}, {2,-3}, {3,-5}, {5,-9}, {6,-13} }; void setup() { Serial.begin(9600); arm.attach(9); shoulder.attach(5); pull.attach(2); } float calc_shoulder_angle(int x, int y){ //forward kinematics for shoulder static int neg_flag = 0; if(y < 0) { neg_flag = 1; y = abs(y); } static float shoulder_angle, yx_div, q_ang; yx_div = (float)y/x; q_ang = acos( (x*x + y*y +49.91) / (24*sqrt(x*x + y*y)) ); shoulder_angle = atan(yx_div) -q_ang ; if(neg_flag == 0) { shoulder_angle = ( shoulder_angle + q_ang ) + abs(q_ang); } shoulder_angle = shoulder_angle*(57296/1000); if(neg_flag){ shoulder_angle = shoulder_angle - 90; shoulder_angle = shoulder_angle + (2*q_ang*(57296/1000)); neg_flag = 0; } return shoulder_angle; } float calc_arm_angle(int x, int y){ //forward kinematics for arm static float arm_angle; arm_angle = acos( (x*x + y*y -238.09) / (232.8) ); arm_angle = arm_angle*(57296/1000); return arm_angle; } void set_angles(int x, int y){ //set angles of shoulder and arm servos static int a_ang,s_ang; s_ang = (int)calc_shoulder_angle(x,y); a_ang = (int)calc_arm_angle(x,y); arm.write(180 - a_ang); //invert arm angle to robot arm bends the other way shoulder.write( abs_to_servo(s_ang) ); } int abs_to_servo (int abs_ang){ // converts from absolute angles (unit circle) to servo angles static int servo_ang; servo_ang = 90 + abs_ang; return servo_ang; } void pull_lever(void){ //pull the spray bottle lever pull.write( abs_to_servo(-40) ); delay(1000); pull.write( abs_to_servo(67)); } void loop() { //goes to each planter box aquare and pulls lever for(int i=0; i<12; i++){ set_angles(xy_points[i][0], xy_points[i][1]); pull_lever(); delay(1500); } } |
The calc_shoulder_angle function is dodgy … Continue reading