KRITSADA

POP-X2 Servo ARM Fence Machine

Mar 30th, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <popx2.h>  // POP-X2 Board
  2. word j=0;
  3. void setup() {
  4.   setTextSize(3);
  5.   setTextColor(GLCD_YELLOW);
  6.   glcd(1,1,"COUNT");
  7.   setTextColor(GLCD_GREEN);
  8. }
  9. void x(){
  10.   int i;
  11.   for(i=50;i<140;i++){
  12.     servo(1,i);delay(2);
  13.   }
  14.   j++;
  15.   glcd(2,1,"%d ",j);
  16. }
  17. void y(){
  18.   int i;
  19.   for(i=140;i>50;i--){
  20.     servo(1,i);delay(8);
  21.   }
  22. }
  23.  
  24. void loop() {
  25. if(analog(2)>500){
  26.   x();delay(3000);y();delay(500);}
  27. }
Advertisement
Add Comment
Please, Sign In to add comment