Go Down

Topic: Coding an Alarm- need help with code (Read 395 times) previous topic - next topic

Hi, me and my friend are making a school project where we are making an alarm.
The things we've used are a LED-display, a PIR-sensor, a piezo speaker and a keypad.

Basicly what we want to do is a functioning alarm that can be turned on and off with a code on the keypad, the led-display shows the current state of the alarm. The PIR-sensor will be used as the detector and the piezo speaker will turn on when the alarm is activated and the PIR-sensor sees movement.

The thing is that we've never worked with Arduino before and are quite frankly not very good at programming.
We have alot of code already though, which has all the basic features that we want with the alarm, but this code doesn't use the PIR-sensor or a keypad, it uses a photoresistor and 4 basic buttons instead. And we've realized that our knowledge in Arduinoprogramming isn't enough to make this work in the right time.

We would really appriciate if someone would be willing to help us with the code to make the PIR-sensor and the keypad work instead of using the four basic buttons and the photoresistor.

Link of all the components we're using.
http://arduino.cc/en/Main/arduinoBoardUno
http://www.elektor.nl/Uploads/Files/Product/EB005.1.pdf
http://www.parallax.com/tabid/768/productid/83/default.aspx
7pin basic keypad
standard piezo speaker

We're also attaching the code we've done so far.


Erdin

I didn't check the whole code, and I can't test it because I don't have the hardware.
But you have good indents with good comments and good names for functions and variables. Well done.

You could make a few files. In the upper-right corner of the Arduino IDE (the Arduino software) is a drop down button.
If you place the keypad code in a function in seperate file, it make things easier.
Perhaps you could also create a *.h file and copy the defines into it. That will also make it easier.

Is the keypad function working ?
You can test it in a new test sketch. Send the characters to the serial port, so you can see what is going on.

Detecting the code can be done in so many ways. I see that you use a "state machine". That is good, but it is easy to make a mistake in the code.
Do you put a '*' character on the LCD if a number is pressed ?

Go Up