Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ATX2.h>
- #define SV4_OPEN_ANGLE 165
- #define SV4_CLOSE_ANGLE 85
- int x1, x2, x3;
- bool SW_L, SW_R;
- void setup(){
- OK();
- glcdClear();
- glcdMode(1);
- setTextSize(2);
- glcd(1,1,"SV1:");
- glcd(2,1,"SV2:");
- glcd(3,1,"SV3:");
- glcd(4,1,"SV4:");
- servo(4, SV4_OPEN_ANGLE);
- setTextColor(GLCD_GREEN);
- glcd(4,5,"OPEN ");
- }
- void loop(){
- x1 = knob(180);
- x2 = map(analog(6), 0, 1023, 30, 90);
- x3 = map(analog(7), 0, 1023, 30, 100);
- SW_L = in(28);
- SW_R = in(29);
- servo(1, x1);
- servo(2, x2);
- servo(3, x3);
- if(SW_L == 0 && SW_R == 1)
- {
- servo(4, SV4_OPEN_ANGLE);
- setTextColor(GLCD_GREEN);
- glcd(4,5,"OPEN ");
- }
- else if(SW_L == 1 && SW_R == 0)
- {
- servo(4, SV4_CLOSE_ANGLE);
- setTextColor(GLCD_RED);
- glcd(4,5,"CLOSE");
- }
- setTextColor(GLCD_WHITE);
- glcd(1,5," %d ",x1);
- glcd(2,5," %d ",x2);
- glcd(3,5," %d ",x3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement