Please use [ code ] tags next time (in the full editor, it's the button which looks like </>) Without code tags, the forum software eats some of your code.
That's a good start. Now look at BlinkWithoutDelay (in the 02Digital examples) and work out how to turn off the LED 1.5 seconds after it went on. Later, you can extend that to the 5-minute siren time.
Piezo on the left, instead of alarm siren. Push button on bottom right, instead of vehicle door switch. Set up as per code posted above. I simulated the code and it basically does what I want it to.
Oh, I also modified the above code a little bit. Red words were swapped. LOW was HIGH. HIGH was LOW.
===
// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter % 4 == 0) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
The image now appears. But it's a F**ing breadboard. That raises so many questions:
OK, you don't have a piezo but what kind of siren do you have? Does it take a 5V logic input or is it expecting 12V power? An Arduino pin can't provide power for a siren.
Where is the power coming from? Which pin on the Arduino have you connected to and what protection do you have against spikes coming from the car?
Do you really know how to wire to those little tactile switches or do you have some other kind of button which isn't in the F**ing library?
If you must use F**ing, please use the schematic view. Otherwise it's difficult to continue the conversation about the actual problems you have.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Thanks.. Tom...
I know. I'm sorry, I couldn't change the color when using the scroll box.
MorganS:
The image now appears. But it's a F**ing breadboard. That raises so many questions:
OK, you don't have a piezo but what kind of siren do you have? Does it take a 5V logic input or is it expecting 12V power? An Arduino pin can't provide power for a siren.
Where is the power coming from? Which pin on the Arduino have you connected to and what protection do you have against spikes coming from the car?
Do you really know how to wire to those little tactile switches or do you have some other kind of button which isn't in the F**ing library?
If you must use F**ing, please use the schematic view. Otherwise it's difficult to continue the conversation about the actual problems you have.
I'm not using Fritzing, I can't get it on my chromebook.
I'm using, https://circuits.io/
Can I not use a relay and have arduino close the relay to run the 12v through the relay?
I plan on using Vin, but need someway to protect against spike. Can I use the usb car charger hack I mentioned above?
3.I'm basically using the door switch for the dome lights in place of the little button. Like I said, it's very basic with what I could use on my chromebook.
It would help if you could label this "door switch" on the schematic. But you can't connect a 12V switch directly to the Arduino. You need a protection resistor of about 1K to 10K there. Then consider that this makes a voltage divider with your pullup resistor. (It may not be 12V now, but what if someone turns the light switch to the 'door' setting?)
Try not to draw components on top of each other on the schematic. Lay it out with some left-to-right flow: put the switch on the left and the output on the right.
Everything connects to ground, so use the ground symbol to show that instead of long ground wires all over the schematic.
OK. So just any resistor that brings the volts down to 5v or less and it'll be fine? Do I put it inline between the switch and the Arduino on the blue wire?
Also, I noticed that the push button has to be grounded to the Arduino board. How would I go about doing that with the dome light switch in my vehicle? Here is the type of switch I'm talking about. Dome Light Switch
Would I just ground the Arduino to my vehicle/battery?
I would like the wireless relay to "activate/deactivate" the Arduino/"alarm."
The "R"s with the question marks are where I think resistors should go.
The "A" with the question mark is because I'd like to know how many amps the Arduino puts out.
The 13.1volts/73ohms=.179amps is how much current I think it takes to activate the coil on the relay I'd like to use for the siren.
Does the schematic look correct? Is there anything I should change? How would I code it for my setup?
Thanks!
Edit: I misread that the wireless relay is intended to power the Arduino. Use a phone charger that outputs 5V and connect that to the 5V pin. A simple resistor won't work to drop the voltage.
For the input from the dome lights, you need a voltage divider: two resistors. Look up voltage divider on Google.
For the output to the relay for the siren, most relays can't be driven directly from an Arduino pin. They need 100-200mA and the pin can only source or sink about 20mA. (40mA is the absolute maximum.) Your calculation shows 179mA and that's at 13V too. The Arduino doesn't output 13V. To do that, you need a transistor and a few other components. It's easiest to buy a relay board designed for Arduino.
Hi,
You need to check that your door switch switches gnd or batt pos.
Most cars have gnd switching, this makes for a very simple mechanical door switch.
TomGeorge:
Hi,
You need to check that your door switch switches gnd or batt pos.
Most cars have gnd switching, this makes for a very simple mechanical door switch.
Tom...
Ok. So I just checked the wiring diagram I have for my vehicle and yes, it looks like the dome light switch switches ground. But, what I would really like to do is splice into the dome light that way whenever any door is opened all the lights come on and it "triggers" the Arduino/alarm. Because, I think if I use just the one switch, it'll only "trigger" the Arduino/alarm when that one door is opened. I could be wrong but I'd rather just do what I stated and splice into a light. So, is there any way to detect said voltage coming from the the wire splice and have the Arduino "trigger" the alarm and make the siren go off?
You are thinking backwards. You are thinking that 12V is "ON". In a lot of cases this is true, but in this case it isn't.
The switch at the doors is "active low" which means that its "activated" position, with the door open is actually a low voltage = 0V. (It is also a little unusual because "active" is also when there's nothing pressing on the switch and "inactive" is when the door is closed and pressing the switch, but we can ignore that for now.)
So if "ON" is 0V, what is "OFF"? Think about the filament of the domelight. With 12V across the filament, current flows and it lights up. If current is zero, then the voltage across the filament is also zero. Since one end is connected to 12V all the time, then the other end must be 12V when it's "OFF".
All the door switches are connected together to one wire. If that wire is grounded at any switch, then the light will come on. So if you connect to one door, you have connected to all the doors. (Unless your car is fancy enough to show you which individual door has been left open, then you should connect to the domelight selector switch.)
So, if 12V is OFF and 0V is ON, that's easy enough to connect to an Arduino with a suitable voltage divider (pair of resistors) and then you can write your logic as follows:
boolean domelightStatus = digitalRead(domeLightPin);
if(domelightStatus == LOW) {
//at least one door is open
...
} else {
//all doors are closed
...
}