# data[].attributes.body
int CdS = A0;

int LED = 4;

int val = 0;

void setup()

{

pinMode(LED, OUTPUT);

Serial.begin(9600);

}

void loop()

{

val = analogRead(CdS);

Serial.print(val);

Serial.print("\n");

if(val > 1020) {

digitalWrite(LED, HIGH);

delay(1000);

digitalWrite(LED, LOW);

delay(1000);

} else {

int CdS = A0;

int LED = 4;

int val = 0;

void setup()

{

pinMode(LED, OUTPUT);

Serial.begin(9600);

}

void loop()

{

val = analogRead(CdS);

Serial.print(val);

Serial.print("\n");

if(val > 1020) {

digitalWrite(LED, HIGH);

delay(1000);

digitalWrite(LED, LOW);

delay(1000);

} else {

digitalWrite(LED, LOW);

delay(100);

}

delay(500);

}

delay(100);

}

delay(500);

}

# data[].attributes.headline
조도센서 LED 서보모터

# data[].attributes.subject
조도센서 LED 서보모터

# data[].attributes.body
#include "Servo.h"

Servo myservo;

int CdS = A0;

int LED = 4;

int val = 0;

void setup()

{

pinMode(LED, OUTPUT);

Serial.begin(9600);

myservo.attach(3);

}

void loop()

{

val = analogRead(CdS);

Serial.print(val);

Serial.print("\n");

if(val < 20) {

digitalWrite(LED, HIGH);

myservo.write(90);

} else {

digitalWrite(LED, LOW);

myservo.write(0);

}

delay(500);

}

# data[].attributes.body
#include "Servo.h"

Servo myservo;

#define IR_TRIG 6

#define IR_ECHO 5

float duration,distance;

int LED = 4;

void setup() {

Serial.begin(9600);

pinMode(IR_TRIG, OUTPUT);

pinMode(IR_ECHO, INPUT);

myservo.attach(3);

pinMode(LED, OUTPUT);

}

void loop()

{

digitalWrite(IR_TRIG, HIGH);

delayMicroseconds(10);

digitalWrite(IR_TRIG, LOW);

duration = pulseIn(IR_ECHO, HIGH);

distance = ((float)(340 * duration) / 10000) / 2;

Serial.print("\nDIstance : ");

Serial.println(distance);

if(distance<20){

{

myservo.write(90);

digitalWrite(LED, HIGH);

delay(1000);

}

}

if(distance>20){

{

myservo.write(0);

digitalWrite(LED, LOW);

delay(1000);

}

}

}

# data[].attributes.headline
초음파센서 LED 서보모터

# data[].attributes.subject
초음파센서 LED 서보모터

# data[].attributes.body
#include "Servo.h"

Servo myservo;

#define IR_TRIG 6

#define IR_ECHO 5

float duration,distance;

int LED = 4;

void setup() {

Serial.begin(9600);

pinMode(IR_TRIG, OUTPUT);

pinMode(IR_ECHO, INPUT);

myservo.attach(3);

pinMode(LED, OUTPUT);

}

void loop()

{

digitalWrite(IR_TRIG, HIGH);

delayMicroseconds(10);

digitalWrite(IR_TRIG, LOW);

duration = pulseIn(IR_ECHO, HIGH);

distance = ((float)(340 * duration) / 10000) / 2;

Serial.print("\nDIstance : ");

Serial.println(distance);

if(distance<20){

{

myservo.write(90);

digitalWrite(LED, HIGH);

delay(1000);

}

}

if(distance>20){

{

myservo.write(0);

digitalWrite(LED, LOW);

delay(1000);

}

}

}

# data[].attributes.body
#include "Servo.h"

Servo myservo;

int CdS = A0;

int val = 0;

void setup()

{

myservo.attach(3);

Serial.begin(9600);

}

void loop()

{

val = analogRead(CdS);

Serial.print(val);

Serial.print("\n");

if(val < 30) {

myservo.write(90);

delay(100);

} else {

myservo.write(0);

delay(100);

}

delay(500);

}

# data[].attributes.body
#define IR_TRIG 6

#define IR_ECHO 5

float duration,distance;

int LED = 4;

void setup() {

Serial.begin(9600);

pinMode(IR_TRIG, OUTPUT);

pinMode(IR_ECHO, INPUT);

pinMode(LED, OUTPUT);

}

void loop()

{

digitalWrite(IR_TRIG, HIGH);

delayMicroseconds(10);

digitalWrite(IR_TRIG, LOW);

duration = pulseIn(IR_ECHO, HIGH);

distance = ((float)(340 * duration) / 10000) / 2;

Serial.print("\nDIstance : ");

Serial.println(distance);

if(distance<20){

{

digitalWrite(LED, HIGH);

delay(1000);

}

}

else{

{

digitalWrite(LED, LOW);

delay(500);

}

}

}