arduino - Can the PIR sensor work without loop? -


void setmanual(){ //do turn on , off light } void setauto(){   for(;;){      digitalread(pirpin); //read data pir      digitalwrite(ledpin, pirvalue); // turn on , of light follow pir's data   } } 

my problem when call setauto(), cannot go method.
have no idea this. so, can pir sensor work without loop? or how can break loop go method?

you cannot go method because

for(;;) 

is infinite loop.

you can read sensor using timer, elapsed millis, in in main loop() statement perhaps delay in between. lots of ways it. entering infinite loop in separate not want program matures completion. main loop() in arduino code infinite loop , 1 should use.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -