hi to every one,
i need some little help from you, if its possible,
i made a simple inclinometer with a potentiometer, reads from -135 to 135 on my lcd , so there are even 2 leds and a buzzer, when the potentiometer reads more than -15 the red led and the buzzer turns on, and when it reads more than 15 the green led and the buzzer turns on. all is working fine.
i just want to delay the buzzer, 1 sec on 5 sec off, and i tried every thing, but when i delay the buzzer it delays me the analog signal from the potentiometer too.
i am new with arduino and codes.
here is my code
``` int ledpinred = 13;
int ledpingreen = 12;
int buzzerpin = 11;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LCD panel
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
lcd.begin(16, 2); // start the library
lcd.print(" INCLINOMETER"); // title of sorts,
pinMode(ledpinred,OUTPUT);
pinMode(ledpingreen,OUTPUT);
pinMode(buzzerpin,OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
int sensorValue = analogRead(A1);
float angle = map (sensorValue, 0, 1023, -135, +135);
// print out the value you read:
Serial.print("current angle (o): ");
Serial.println(angle);
lcd.setCursor(0, 1); // set the LCD cursor position
lcd.print(angle); //display final degrees
//print the degrees symbol at the end
lcd.print("o");
//wait 0.1 seconds
delay(100);
//wipe the extra characters
lcd.print(" ");
delay(1);
if (angle < -15){
digitalWrite(ledpinred,HIGH);
digitalWrite(buzzerpin,HIGH);
delay(1000);
digitalWrite(buzzerpin,LOW);
delay(5000);}
else{
digitalWrite(ledpinred,LOW);
}
if (angle > 15){
digitalWrite(ledpingreen,HIGH);
digitalWrite(buzzerpin,HIGH);
delay(1000);
digitalWrite(buzzerpin,LOW);
delay(5000);}
else{
digitalWrite(ledpingreen,LOW);}}
>
][/code]
thanks in advance