Hello,
Im pretty new to arduino, I have a Etherten with a 4884 lcd shield on it.
My friend is building a hotrod and wanted a small display to show warning indications as at the moment he only has leds which dont really show him quickly what the problem is.
I have 2 issues and Im not sure how to solve them Im hoping you can help.
One is I would like the seatbelt icon to stay on constantly when drawn low by pin10, at the moment it just flickers but I still need another warning to come up if they draw any other pins low. Ie if pin 8 goes low I want that warning icon to come up and the buzzer to go off but the other icon that may be active to stay displayed. Just like on you car dashboard. Not sure if this can be achieved with one screen, or even this arduino.
I have placed my code below.
Thankyou in advance
#include "LCD4884.h"
#include "lowfuel.h" // this file needs to be in the same folder as your sketch
int z=0; //joystick position
int dd=200; //joystick delay
int screenback=digitalRead(7);//screen back light
int name=1; //show cobra text
int image3=0;
void setup(){
//lcd startup
lcd.LCD_init(); // creates instance of LCD
lcd.LCD_clear(); // blanks the display
pinMode(7, OUTPUT);
//start serial connection
// Serial.begin(9600);
//configure as an input and enable the internal pull-up resistor
pinMode(9, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(13, OUTPUT); //buzzer
}
void loop(){
//lowfuel ******************
//read the pin9 value into a variable
int sensorVal = digitalRead(9);
//print out the value of the pin9
if(name=1){
//lcd.LCD_write_string(0,5,"AC COBRA DIAG", MENU_NORMAL); // ignore MENU_NORMAL for now
//do { } while (1>0);
// Serial.print(name);
// delay(2000);
}
Serial.print("pin9: ");
Serial.println(sensorVal);
if (sensorVal == LOW) {
tone(13, 3000,1000);
lcd.LCD_draw_bmp_pixel(0,0, lowfuel, 20,20);
delay(1000);
lcd.LCD_draw_bmp_pixel(0,0, lowfuelblank, 20,20);;
delay(1000);
}
else {
lcd.LCD_clear();
digitalWrite(13, LOW);
}
//END low fuel **********************************
//engine fail **********************************
int sensorVal2 = digitalRead(8);
//print out the value of the pin8
Serial.print("pin8: ");
Serial.println(sensorVal2);
if (sensorVal2 == LOW) {
tone(13, 3000,1000);
lcd.LCD_draw_bmp_pixel(0,10, enginefail, 20,20);
delay(1000);
lcd.LCD_draw_bmp_pixel(0,10, enginefailblank, 20,20);
delay(1000);
}
else {
lcd.LCD_clear();
digitalWrite(13, LOW);
}
//END engine fail **********************************
//Seatbelt, this should stay constant on when pin10 goes low
int sensorVal3 = digitalRead(10);
//print out the value of the pin10
Serial.print("pin10: ");
Serial.println(sensorVal3);
if (sensorVal3 == LOW) {
//tone(13, 3000,1000);
lcd.LCD_write_string(0,5,"Seatbelt", MENU_NORMAL); // ignore MENU_NORMAL for now
lcd.LCD_draw_bmp_pixel(20,00, seatbelt, 20,20);
//
delay(100);
}
else {
lcd.LCD_draw_bmp_pixel(20,00, seatbeltblank, 20,20);
digitalWrite(13, LOW);
}
//end seatbelt
//centre joystick button pushed backlight off
z=analogRead(0);
Serial.println(z);
Serial.println(screenback);
if (z>140 && z<150)
{
if (screenback==1)
{
digitalWrite(7,LOW);
screenback=digitalRead(7);
Serial.println("off");
}
else
{
digitalWrite(7,HIGH);
screenback=digitalRead(7);
}
z=0;
}
}
regards,
Steve