Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Created October 16, 2015 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neosarchizo/b9e45002dd00566a8a08 to your computer and use it in GitHub Desktop.
Save neosarchizo/b9e45002dd00566a8a08 to your computer and use it in GitHub Desktop.
[ICT DIY] 아두이노로 전등 스위치 제어하기
#include <Servo.h>
#include <SoftwareSerial.h>
SoftwareSerial btSerial(10,11);
Servo myServo;
void setup() {
write(180);
btSerial.begin(9600);
}
void loop() {
if(btSerial.available()){
char c = btSerial.read();
switch(c){
case 'a':
write(180);
break;
case 'b':
write(110);
break;
}
}
}
void write(int angle) {
myServo.attach(9);
myServo.write(angle);
delay(1000);
myServo.detach();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment