برمجة الاردينوا :-
int motion = 5;
int motionLed = 7;
void setup() {//ok i need to state what each pin will be doing. the led pin will//be an output and the motion pin will be an input.
Serial.begin(9600);
pinMode(motion, INPUT);
pinMode(motionLed, OUTPUT);}
void loop(){ //what will happen in the sketch //if motion is detected we want to turn the led light on //if no motion is detected turn the led off //you also need to declare a variable to hold the sensor data long sensor = digitalRead(motion); //then the if statement to control the led
long sensor = digitalRead(motion);
if(sensor == HIGH){
digitalWrite (motionLed, HIGH);
Serial.println(1);
}
else {
digitalWrite (motionLed, LOW);
Serial.println(0);
}
delay(2000);
0 التعليقات:
إرسال تعليق