12v sennse and a button
ok have 2 questions id input;
1st need arduino sense when circuit has activated 12v circuit how safely connect 2?
2nd question need momentary switch go hgh , stay high no matter how many times pressed ideas?
here code not tested yet because i'm still waiting parts.
[quote//#include <liquidcrystal.h>
//liquidcrystal lcd(13,12,11,10,a5,a4)
// input pins
int pirpin = 8;
int doorpin = 7;
int setpin = 6;
int disarmpin = 5;
//output pins
int sirenpin = 4;
int siren2pin = 3;
int strobepin = 9;
//var
void setup()
{
pinmode(pirpin, input);
pinmode(doorpin, input);
pinmode(setpin, input);
pinmode(disarmpin, input);
pinmode(sirenpin, output);
pinmode(siren2pin, output);
pinmode(strobepin, output);
}
void loop()
{
if (digitalread(setpin) == high && digitalread(pirpin) == high)
{
digitalwrite(sirenpin, high); digitalwrite(strobepin, high);
//delay(900000);
//digitalwrite(sirenpin, low);
}
else
{
digitalwrite(sirenpin, low);
}
if (digitalread(setpin) == high && digitalread(doorpin) == high)
{
digitalwrite(sirenpin, high); digitalwrite(strobepin, high);
}
else
{
digitalwrite(sirenpin, low);
}
if (digitalread(setpin) == high && digitalread(doorpin) == high && digitalread(pirpin) == high)
{
digitalwrite(sirenpin, high); digitalwrite(strobepin, high);
}
else
{
digitalwrite(sirenpin, low);
}
if (digitalread(disarmpin) == high)
{
digitalwrite(sirenpin, low); digitalwrite(strobepin, low);
}
}
[/quote]
1st need arduino sense when circuit has activated 12v circuit how safely connect 2?
2nd question need momentary switch go hgh , stay high no matter how many times pressed ideas?
here code not tested yet because i'm still waiting parts.
[quote//#include <liquidcrystal.h>
//liquidcrystal lcd(13,12,11,10,a5,a4)
// input pins
int pirpin = 8;
int doorpin = 7;
int setpin = 6;
int disarmpin = 5;
//output pins
int sirenpin = 4;
int siren2pin = 3;
int strobepin = 9;
//var
void setup()
{
pinmode(pirpin, input);
pinmode(doorpin, input);
pinmode(setpin, input);
pinmode(disarmpin, input);
pinmode(sirenpin, output);
pinmode(siren2pin, output);
pinmode(strobepin, output);
}
void loop()
{
if (digitalread(setpin) == high && digitalread(pirpin) == high)
{
digitalwrite(sirenpin, high); digitalwrite(strobepin, high);
//delay(900000);
//digitalwrite(sirenpin, low);
}
else
{
digitalwrite(sirenpin, low);
}
if (digitalread(setpin) == high && digitalread(doorpin) == high)
{
digitalwrite(sirenpin, high); digitalwrite(strobepin, high);
}
else
{
digitalwrite(sirenpin, low);
}
if (digitalread(setpin) == high && digitalread(doorpin) == high && digitalread(pirpin) == high)
{
digitalwrite(sirenpin, high); digitalwrite(strobepin, high);
}
else
{
digitalwrite(sirenpin, low);
}
if (digitalread(disarmpin) == high)
{
digitalwrite(sirenpin, low); digitalwrite(strobepin, low);
}
}
[/quote]
would work?
code: [select]
if digitalread(setpin, high);
digitalwrite(setpin, high);
else digitalwrite(sepin, high);
Arduino Forum > Using Arduino > General Electronics > 12v sennse and a button
arduino
Comments
Post a Comment