Donal
/
full_lamp
gfdh
main.cpp@0:534254739887, 2015-04-23 (annotated)
- Committer:
- Qoramas
- Date:
- Thu Apr 23 16:45:16 2015 +0000
- Revision:
- 0:534254739887
test;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Qoramas | 0:534254739887 | 1 | #include "mbed.h" |
Qoramas | 0:534254739887 | 2 | #include "C12832.h" |
Qoramas | 0:534254739887 | 3 | |
Qoramas | 0:534254739887 | 4 | C12832 lcd(p5, p7, p6, p8, p11); |
Qoramas | 0:534254739887 | 5 | |
Qoramas | 0:534254739887 | 6 | Serial pc(USBTX, USBRX); |
Qoramas | 0:534254739887 | 7 | |
Qoramas | 0:534254739887 | 8 | float x, y; |
Qoramas | 0:534254739887 | 9 | |
Qoramas | 0:534254739887 | 10 | PwmOut Servo_X(p21); |
Qoramas | 0:534254739887 | 11 | PwmOut Servo_Y(p22); |
Qoramas | 0:534254739887 | 12 | PwmOut Servo_Z(p23); |
Qoramas | 0:534254739887 | 13 | |
Qoramas | 0:534254739887 | 14 | int main() { |
Qoramas | 0:534254739887 | 15 | while(1) { |
Qoramas | 0:534254739887 | 16 | // Top left = 0.08 x 0.055 y |
Qoramas | 0:534254739887 | 17 | // Bottom right = 0.065 x 0.07y |
Qoramas | 0:534254739887 | 18 | |
Qoramas | 0:534254739887 | 19 | //0-1x -> 0.08-0.065x |
Qoramas | 0:534254739887 | 20 | //0-1y -> 0.055-0.07y |
Qoramas | 0:534254739887 | 21 | if (pc.readable()) |
Qoramas | 0:534254739887 | 22 | pc.scanf("%f,%f", &x, &y); |
Qoramas | 0:534254739887 | 23 | |
Qoramas | 0:534254739887 | 24 | float setX = 0.08f - (x * 0.015); |
Qoramas | 0:534254739887 | 25 | float setY = 0.055f + (y * 0.015); |
Qoramas | 0:534254739887 | 26 | |
Qoramas | 0:534254739887 | 27 | //Servo_X = setX;// 0.05 min 0.09 max |
Qoramas | 0:534254739887 | 28 | //Servo_Y = setY; // Top left |
Qoramas | 0:534254739887 | 29 | Servo_X = 0.08; |
Qoramas | 0:534254739887 | 30 | Servo_Y = 0.055; |
Qoramas | 0:534254739887 | 31 | Servo_Z = 0.07; |
Qoramas | 0:534254739887 | 32 | |
Qoramas | 0:534254739887 | 33 | |
Qoramas | 0:534254739887 | 34 | lcd.cls(); |
Qoramas | 0:534254739887 | 35 | lcd.locate(0,0); |
Qoramas | 0:534254739887 | 36 | lcd.printf("X: %f, Y: %f Z: %f", x, y, Servo_Z); |
Qoramas | 0:534254739887 | 37 | |
Qoramas | 0:534254739887 | 38 | wait(1); |
Qoramas | 0:534254739887 | 39 | } |
Qoramas | 0:534254739887 | 40 | } |