Skip to content

Instantly share code, notes, and snippets.

@vasmani
Last active February 23, 2016 04:02
Show Gist options
  • Select an option

  • Save vasmani/2c5dfd4cc8ac328fca71 to your computer and use it in GitHub Desktop.

Select an option

Save vasmani/2c5dfd4cc8ac328fca71 to your computer and use it in GitHub Desktop.
구피 사료주기 - RF와 모터 이용
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
#include <Servo.h>
RCSwitch mySwitch = RCSwitch();
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(9);
mySwitch.enableReceive(0);
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if(value == 1111){
for(int i=0; i < 7; i++){
for(pos = 15; pos < 170; pos += 1){
myservo.write(pos);
delay(10);
}
for(pos = 170; pos>=15; pos-=1){
myservo.write(pos);
delay(10);
}
}
myservo.write(15);
}
mySwitch.resetAvailable();
delay(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment