Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "servo.h"
- void Servo::Servo():pinnummer(i){
- pinMode(pinnummer, Output);
- status = 0;
- }
- int Servo::getstatus(){
- return status;
- }
- void Servo::Opendoor()
- {
- int current = 0;
- for(current = 700; current < 2200; current += 10){
- digitalWrite(pinnummer, HIGH);
- delayMicroseconds(current);
- digitalWrite(pinnummer, LOW);
- delayMicroseconds(2800 - current);
- }
- }
- void Servo::Closedoor(){
- int current = 0;
- for(current = 2400 ; current > 700; current -= 10){
- digitalWrite(pinnummer, HIGH);
- delayMicroseconds(current);
- digitalWrite(pinnummer, LOW);
- delayMicroseconds(2800 - current);
- }
- }
- int main (){
- Servo voordeuur(3)
- Knop knopdeur(4)
- while(1){
- if(knopdeur.getstatus() == 1)
- voordeur.opendoor();
- }
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement