Show Posts
|
|
Pages: [1] 2 3 ... 10
|
|
4
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial input to LCD problem
|
on: April 20, 2009, 06:14:37 pm
|
My problem is that it seems to overwrite itself sometimes try inserting lcd.clear(); in some cases that might help  Try This, I Think I Fixed It For You  #include <LCD4Bit.h>
LCD4Bit lcd = LCD4Bit(2);
int x = 0; int i =0; int button = 13; char g[53]=""; char u[25]=""; char ut[25]=""; char l[25]=""; char lt[25]=""; char b[25]=" "; int scrolled=0;
void setup() { lcd.init(); Serial.begin(19200); }
void loop() { lcd.clear(); // Serial data waiting? if (Serial.available()) { delay(100); // Read in the serial data to g while(Serial.available()>0) { g[x]=Serial.read(); x++; } x=0; char ch = g[x]; // Begin filling the upper temp, until the % character while (g[x] != '%') { ut[x-1]=g[x]; x++; } // Was that actually wanted data? if (g[0] != '$') { // If not, clear the upper temp for(int i = 0; i < 25; i++) { ut[i]=' '; } } // Fill the rest to the lower temp until ^ character while(g[x+1] != '^') { x++; lt[i]=g[x]; i++; } x=0; i=0; // Clear g for(int i = 0; i < 53; i++) { g[i]=' '; } // Upper temp not empty? if (ut[0] != ' ') { // Clear upper line lcd.cursorTo(1,0); delay(1); lcd.printIn(b); delay(10); // Print new data lcd.cursorTo(1,0); delay(1); lcd.printIn(ut); delay(10); // Save temp for(int i = 0; i < 25; i++) { u[i]=ut[i]; ut[i]=' '; } } // Lower temp not empty? if (lt[0] != ' ') { // Clear lower line lcd.cursorTo(2,0); delay(1); lcd.printIn(b); delay(10); // Print new data lcd.cursorTo(2,0); delay(1); lcd.printIn(lt); delay(10); // Save temp for(int i = 0; i < 25; i++) { l[i]=lt[i]; lt[i]=' '; } } } // Otherwise, check if we should be scrolling while(!(Serial.available() > 0)) { lcd.clear(); delay(1500); // Scroll if the string is off the screen if((u[16] != ' ')||(u[17] != ' ')||(l[16] != ' ')||(l[17] != ' ')) { lcd.leftScroll(10,750); scrolled=1; } // If scrolled, redraw the text if (scrolled == 1) { lcd.clear(); lcd.cursorTo(1,0); lcd.printIn(u); delay(1); lcd.cursorTo(2,0); lcd.printIn(l); scrolled=0; } } }
|
|
|
|
|
8
|
Forum 2005-2010 (read only) / Syntax & Programs / Virtual latching relay
|
on: March 30, 2009, 11:49:22 am
|
//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); } }
ive been posting that alot, but i need to know how to have it once the button is activated, it wont stop till i press the reset button on the arduino duemilinove.
|
|
|
|
|
12
|
Forum 2005-2010 (read only) / Syntax & Programs / It Dont Work Right :(
|
on: March 27, 2009, 11:17:27 pm
|
//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 :-?
|
|
|
|
|