Pages: [1]   Go Down
Author Topic: It Dont Work Right :(  (Read 1161 times)
0 Members and 1 Guest are viewing this topic.
Glassport,Pa@ USA
Offline Offline
Full Member
***
Karma: 0
Posts: 150
shoop teh whoop!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote

 
//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(".");
        delay(1000);
        lcd.print("..");
                delay(1000);
        lcd.print("...");
    delay(1000);
      lcd.print("System Stats: Standby");
    digitalWrite(buzzerPin, LOW);
    digitalWrite(ledPin, LOW);
    digitalWrite(truPin, LOW);
delay(2000);
}


  

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
    delay(50);
    digitalWrite(ledPin, LOW);
    delay(50);
    digitalWrite(buzzerPin, HIGH);
      lcd.print("CHECK PULL STATIONS");
    delay(50);
    lcd.print("OR TEST SWITCH");
    digitalWrite(buzzerPin, LOW);
    delay(50);
    digitalWrite(Alarms, HIGH);
  } else {
      lcd.print("Standby.");
    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.

Circuit:


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

[ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618]

Glassport,Pa@ USA
Offline Offline
Full Member
***
Karma: 0
Posts: 150
shoop teh whoop!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

bump.
Logged

[ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618]

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This forum needs administration  :-?
Logged

My website: http://ried.cl

Glassport,Pa@ USA
Offline Offline
Full Member
***
Karma: 0
Posts: 150
shoop teh whoop!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

this thread is about helping me, shoo
Logged

[ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618]

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6782
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 491
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Andrew
« Last Edit: March 28, 2009, 01:04:20 pm by Andrew » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Lefty
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley-grin

Thank you.

--Phil.
Logged

Glassport,Pa@ USA
Offline Offline
Full Member
***
Karma: 0
Posts: 150
shoop teh whoop!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

follower, i was grounded, but here my school dont block this so horah smiley-grin


anyways thanks for the help every1 smiley-grin ;D ;D ;D ;D ;D ;D
Logged

[ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618][ch9618]

Pages: [1]   Go Up
Jump to: