Go Down

Topic: It Dont Work Right :( (Read 7138 times) previous topic - next topic



//z-parakeet inc.'s Fire Alarm Sketch
#include <LiquidCrystal.h>
// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4, d5, d6, d7 on pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int ledPin = 13; // choose the pin for the LED
int buzzerPin = 9; //buzzer/alertor
int inputPin = 8;               // choose the input pin (for a pushbutton)
int val = 0;            // variable for reading the pin status
int truPin = 7;
int Alarms = 6;
int sil = 0;
void setup() {

 pinMode(buzzerPin, OUTPUT);   //declare BUZZER or allertor as a output!
 pinMode(ledPin, OUTPUT);      // declare LED as output
 pinMode(inputPin, INPUT);  // declare pushbutton as input
 pinMode(truPin, OUTPUT);
 pinMode(Alarms, OUTPUT);
     digitalWrite(buzzerPin, HIGH);
     digitalWrite(ledPin, HIGH);
     digitalWrite(truPin, HIGH);
       lcd.print("System Loading");
     lcd.print("System Stats: Standby");
   digitalWrite(buzzerPin, LOW);
   digitalWrite(ledPin, LOW);
   digitalWrite(truPin, LOW);


void loop(){
 val = digitalRead(inputPin);  // read input value
 delay(0); //used to be a delay, but changed cuz of my update!
 if (val == HIGH) {      // check if the input is HIGH
 lcd.print("ALERT! TROUBLE OR FIRE");
   digitalWrite(truPin, HIGH);
   digitalWrite(ledPin, HIGH);  // turn LED ON
   digitalWrite(ledPin, LOW);
   digitalWrite(buzzerPin, HIGH);
     lcd.print("CHECK PULL STATIONS");
   lcd.print("OR TEST SWITCH");
   digitalWrite(buzzerPin, LOW);
   digitalWrite(Alarms, HIGH);
 } else {
   digitalWrite(ledPin, LOW); // turn LED OFF
   digitalWrite(truPin, LOW);
   digitalWrite(Alarms, LOW);

Theres The Code.
The Problem Is That The Alarm Sounds When Button Is Not Pressed, When Pressed, Nothing Happens, alarm still sounds.


i got it when the alarm led wuz off, but the 6th led on the led chanel wuz the trouble/alarm led :-?


This forum needs administration  :-?
My website: http://ried.cl


this thread is about helping me, shoo


Your inputPin may be floating when the button is not pressed. Try connecting a resistor (anything from 1k to 20k) from the inputPin to ground if you don't already have one.

Or you could wire it using internals pull-ups (a search will provide explanations if you don't know hot to do this)


1) try to use correct grammer and correct spelling.  Also avoid slang/etc (like "wuz".)   Remember that a lot of people on these forums don't speak English as their primary language, so it's asking a lot for them to just READ your posts.  (Being 11 is not excuse; think of yourself as an International Ambassador of American 11-y olds!)

2) Get rid of the lcd.print() stuff if/while you don't have an LCD connected.  I can't speak for the Arduino LCD library, but SOME code will wait for a device to respond, and if there is no device, it hangs.  (This would actually be unusual for an LCD library, but it's still not good practice.)  (Although you do in fact turn the buzzer on first thing, before you try writing to the LCD.  (Why?  Shouldn't it be off to start with?))

3) Better yet, replace lcd.print with Serial.print so you can see what is happening in the Arduino IDE Serial monitor window.  console messages are one of the most primitive debugging mechanisms, but they're still useful.  Then report what it says...

4)  I agree with Mem.  You need a pull-down resistor, or you need to reconfigure the switch and code to use the internal pullup capability.


Mar 28, 2009, 06:59 pm Last Edit: Mar 28, 2009, 07:04 pm by Andrew Reason: 1
It's difficult to see how you've got stuff connected up, but as the others have said you probably have an input pin whose value is undetermined ("floating"). Try the code and circuit from the button tutorial and see if that works: http://arduino.cc/en/Tutorial/Button

If you look at the page on digital pins it explains how you can use builtin resistors on the Arduino ("internal pull-ups") to do the same thing: http://arduino.cc/en/Tutorial/DigitalPins

Nice breadboard system by the way.



this thread is about helping me, shoo

However this forum is not all about helping you. You seem to be somewhat dominating and demanding of attention to your needs.

Even at eleven if you wish to interface with adults you should work on your manners and demeanor and slow down a little. You have lots of time to learn how to learn.



Hi all...

While I appreciate the concern about maintaining the level of discourse and helpfulness in the Arduino forum community, as a community member I am concerned the overall reaction to these posts could be considered by now to be bordering on bullying.

Given that:
  • there's been a whole separate thread devoted to this matter,
  • concerns have been expressed clearly
  • and the pwnz0r (Kevin?) has not posted since the original response
I would like to politely request that people reconsider making any further posts on etiquette and that we return to solving technical problems. And having fun hacking stuff. :-)

pwnz0r, I would like to repeat that you are very welcome to participate in these forums but ask that you realise we don't have a lot of people your age on the forums so being nice to each other and patient on both sides is appreciated. I wish I had had this stuff to play with when I was eleven! :D

Thank you.



follower, i was grounded, but here my school dont block this so horah :D

anyways thanks for the help every1 :D ;D ;D ;D ;D ;D ;D

Go Up