Motion activated lamp - help for a school project


hey guys.
i working on making motion activated lamp arduino uno, breadboard, sparkfun pir motion sensor , relay.
i hooked motion sensor , relay arduino (the power wire both connected breadboard).

so basicly, moition sensor reacts infrared radiation , sends volatge arduino , arduino sends voltage relay (which hooked lamp)  via wire attached pin 13.

i not aware on how know when motion sensor works , how program everything. used sketch code makes lamp turn on , off (blinking) , won't turn off completly. apreciate advice, escpecially on code.

here code:
code: [select]
int motion_1 = 2;
int light_1 = 13;
void setup(){
   pinmode (2,input);
   digitalwrite(2, high);
   
   pinmode (motion_1,input);
   pinmode (light_1, output);
}

void loop (){
   digitalwrite (light_1,low);
   delay(1000); //this delay let sensor settle down before taking reading
   int sensor_1 = digitalread(motion_1);
   if (sensor_1 == low){
     digitalwrite(light_1,high);
     delay(500);
     digitalwrite(light_1,low);
     delay(500);

  }
}

code: [select]
   delay(1000); //this delay let sensor settle down before taking reading
no, isn't. it's crap. sensor doesn't need "time settle down".

code: [select]
   pinmode (2,input);
   digitalwrite(2, high);
   
   pinmode (motion_1,input);

you gave pin name. why addressing number, too. think happening pullup resistor when bit of code executes? restructure sure.



Arduino Forum > Using Arduino > Project Guidance > Motion activated lamp - help for a school project


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support