Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include "servo.h"
  2.  
  3. void Servo::Servo():pinnummer(i){
  4. pinMode(pinnummer, Output);
  5. status = 0;
  6. }
  7.  
  8. int Servo::getstatus(){
  9. return status;
  10. }
  11.  
  12. void Servo::Opendoor()
  13. {
  14.  
  15. int current = 0;
  16. for(current = 700; current < 2200; current += 10){
  17.  
  18. digitalWrite(pinnummer, HIGH);
  19. delayMicroseconds(current);
  20. digitalWrite(pinnummer, LOW);
  21. delayMicroseconds(2800 - current);
  22.  
  23. }
  24. }
  25.  
  26. void Servo::Closedoor(){
  27.  
  28. int current = 0;
  29. for(current = 2400 ; current > 700; current -= 10){
  30. digitalWrite(pinnummer, HIGH);
  31. delayMicroseconds(current);
  32. digitalWrite(pinnummer, LOW);
  33. delayMicroseconds(2800 - current);
  34.  
  35.  
  36. }
  37. }
  38.  
  39. int main (){
  40.  
  41. Servo voordeuur(3)
  42. Knop knopdeur(4)
  43.  
  44.  
  45. while(1){
  46.  
  47. if(knopdeur.getstatus() == 1)
  48. voordeur.opendoor();
  49.  
  50. }
  51. return (0);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement