Advertisement
RuiViana

WTV020_UP_DOWN

Nov 19th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1.  
  2. #define Up    4  //Pino 13 clock
  3. #define Down  5  //Pino 12 clock
  4. char buf;
  5. //-----------------------------
  6. void setup()
  7. {
  8.   Serial.begin(9600);
  9.   pinMode(Up, OUTPUT);
  10.   pinMode(Down, OUTPUT);
  11. }
  12. //-----------------------------
  13. void loop()
  14. {
  15.   if (Serial.available() > 0)
  16.   {
  17.     buf = Serial.read();
  18.     delay(20);
  19.   }
  20.   if (buf == '1')
  21.   {
  22.     digitalWrite(Up, LOW);
  23.     delay(100);
  24.     digitalWrite(Up, HIGH);
  25.     buf = 0;
  26.   }
  27.   if (buf == '2')
  28.   {
  29.     digitalWrite(Down, LOW);
  30.     delay(100);
  31.     digitalWrite(Down, HIGH);
  32.     buf = 0;
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement