Ok another stumper that I need some input for. I am building an AC control unit for a car, and want to display the "temp" setting on the LCD screen, I have a 16x2. I have 2 buttons, for temp up and temp down, which are multiplexed to output on pins 22-30, (I have the MEGA), and go to 3 different cascaded multiplexers, which can give me a total of 24 "temp settings" but I am only using 18. There are 18 LEDS hooked up on a parallell set of multiplexers, so I can watch what is happening. When the system boots, led 1 is on, when temp up is hit, the leds light up increasing until 18 is lit, and opposite for temp down. This part works PERFECT.
Now to get to my question. I want to display something like:
TEMP
C*****XH
on the screen, and have the X move back and forth. The display should last about a second, then go right back to what it was doing before, which was a static display of the outside and inside temperatures. When I add this section in, it adds delay to my loop, and the buttons stop working. I need everything to be as responsive as possible. I am uploading my code and I will try to take a short video so you can see what I am trying to accomplish.
Heres the code, vid will follow:
byte TEMP0 = 0; //analog 8 sensor input
byte TEMP1 = 0; //analog 9 sensor input
int TEMP1F = 0;
int TEMP0F = 0;
int FAN = 0;
int LOC = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte count;
void setup()
{
lcd.begin (16,2); //DISPLAYS OPENING LOGO ONCE
lcd.setCursor (0,0);
lcd.print (" WELCOME TO MY");
lcd.setCursor (0,1);
lcd.print (" CAMARO");
delay (7000);
lcd.clear();
delay(100); //CLEARS 7 SECONDS LATER
//TEMP SENSOR INPUTS
//temp up and down control
pinMode (32, INPUT); //external debounced switch pins 52 is temp up
pinMode (33, INPUT); // 50 is temp down
pinMode (22, OUTPUT); //pinS ODD 37-53 are outputs for multiplexers
pinMode (23, OUTPUT);
pinMode (24, OUTPUT);
pinMode (25, OUTPUT);
pinMode (26, OUTPUT);
pinMode (27, OUTPUT);
pinMode (28, OUTPUT);
pinMode (29, OUTPUT);
pinMode (30, OUTPUT); //END OUTPUT PINS FOR TEMP CHIPS
//fan speed/location control
pinMode (15, INPUT); //reads ADC value from fan speed knob
pinMode (35, OUTPUT); //outputs to s0 on fan driver chip
pinMode (36, OUTPUT); //outputs to s1 on fan driver chip
pinMode (37, OUTPUT); //outputs to s2 on fan driver chip
pinMode (38, OUTPUT); //outputs to s0 on location chip
pinMode (39, OUTPUT); //outputs to s1 on location chip
pinMode (40, OUTPUT); //outputs to s2 on location chip
pinMode (14, INPUT); //reads ADC value from location knob
Serial.begin (9600); //START SERIAL FOR THE HELL OF IT
}
void loop()
//=========================================================================================
//=========================================================================================
//=========================================================================================
//FAN SPEED BLOCK START
{
int FAN = analogRead (15);
//P[IN 34 IS INPUT FROM KNOB
// Trigger notes : 35 is s0, 36 is s1, and 37 is s2
if (FAN < 10 ) //pot detent 1
{digitalWrite (35, LOW);
digitalWrite (36, LOW);
digitalWrite (37, LOW);}
else
{}
if (FAN > 100 && FAN < 250 ) //pot detent 2
{digitalWrite (35, HIGH);
digitalWrite (36, LOW);
digitalWrite (37, LOW);}
else
{}
if (FAN > 251 && FAN < 350 ) //pot detent 3
{digitalWrite (35, LOW);
digitalWrite (36, HIGH);
digitalWrite (37, LOW);}
else
{}
if (FAN > 351 && FAN < 450 ) //pot detent 4
{digitalWrite (35, HIGH);
digitalWrite (36, HIGH);
digitalWrite (37, LOW);}
else
{}
if (FAN > 451 && FAN < 625 ) //pot detent 5
{digitalWrite (35, LOW);
digitalWrite (36, LOW);
digitalWrite (37, HIGH);}
else
{}
if (FAN > 626 && FAN < 775 ) //pot detent 6
{digitalWrite (35, HIGH);
digitalWrite (36, LOW);
digitalWrite (37, HIGH);}
else
{}
if (FAN > 776 && FAN < 950 ) //pot detent 7
{digitalWrite (35, LOW);
digitalWrite (36, HIGH);
digitalWrite (37, HIGH);}
else
{}
if (FAN > 951 ) //pot detent 8
{digitalWrite (35, HIGH);
digitalWrite (36, HIGH);
digitalWrite (37, HIGH);}
else
{}
Serial.println (analogRead (15));
//FAN SPEED BLOCK CLOSE
//=========================================================================================
//=========================================================================================
//TEMP SENSOR BLOCK START
{
int TEMP0 = analogRead(8);
int TEMP0F = TEMP0 * 20 / 10; // converting that reading to voltage, for 3.3v arduino use 3.3
lcd.setCursor(0,0);
lcd.print("OUTSIDE "); lcd.print (TEMP0F); lcd.print("F ");
delay (0);
int TEMP1 = analogRead(9);
int TEMP1F = TEMP1 * 20 / 20; // converting that reading to voltage, for 3.3v arduino use 3.3
lcd.setCursor(0,1);
lcd.print("INSIDE "); lcd.print (TEMP1F); lcd.print("F ");
delay (500);}
//TEMP SENSOR INPUT BLOCK CLOSE
//=========================================================================================
//=========================================================================================
//TEMP CONTROL BLOCK START
{if (digitalRead(33) == HIGH && count < 18)
{count++;
delay (10);}
else if (digitalRead(32) == HIGH && count > 0)
{count--;
delay (10);}
//start sending temp button contact closure commands
if (count == 0)
{digitalWrite (22, LOW);
digitalWrite (23, LOW);
digitalWrite (24, LOW);
digitalWrite (25, LOW);
digitalWrite (26, LOW);
digitalWrite (27, LOW);
digitalWrite (28, LOW);
digitalWrite (29, LOW);
digitalWrite (30, LOW);}
else
{}
//counts all the way from 0 to 17, 18 total. Omittted for space.
if(count == 17)
{ digitalWrite (22, HIGH);
digitalWrite (23, HIGH);
digitalWrite (24, HIGH);
digitalWrite (25, HIGH);
digitalWrite (26, HIGH);
digitalWrite (27, HIGH);
digitalWrite (28, HIGH);
digitalWrite (29, LOW);
digitalWrite (30, HIGH); }
else
{}
//TEMP CONTROL BLOCK CLOSE
//=========================================================================================
//=========================================================================================
//LOCATION CONTROL BLOCK START
{int LOC = analogRead (14);
// PIN 14 IS INPUT FROM KNOB
// Trigger notes : 38 is s0, 39 is s1, and 40 is s2
if (LOC < 10 ) //pot detent 1
{digitalWrite (38, LOW);
digitalWrite (39, LOW);
digitalWrite (40, LOW);}
else
{}
if (LOC > 150 && LOC < 250 ) //pot detent 2
{digitalWrite (38, HIGH);
digitalWrite (39, LOW);
digitalWrite (40, LOW);}
else
{}
if (LOC > 251 && LOC < 450 ) //pot detent 3
{digitalWrite (38, LOW);
digitalWrite (39, HIGH);
digitalWrite (40, LOW);}
else
{}
if (LOC > 451 && LOC < 650 ) //pot detent 4
{digitalWrite (38, HIGH);
digitalWrite (39, HIGH);
digitalWrite (40, LOW);}
else
{}
if (LOC > 651 && LOC < 850 ) //pot detent 5
{digitalWrite (38, LOW);
digitalWrite (39, LOW);
digitalWrite (40, HIGH);}
else
{}
if (LOC > 851 ) //pot detent 6
{digitalWrite (38, HIGH);
digitalWrite (39, LOW);
digitalWrite (40, HIGH);}
else
{}}
//LOCATION CONTROL BLOCK CLOSE
//=========================================================================================
//=========================================================================================
}
}
just noticed some of my pin numbers in my notes dont line up. Cosmetic but Ill fix them.