Grumpy_Mike:
The shift out function will move out one byte at a time. So you define your byte array to have your bytes in it not bits.
Like this:-
OK, I am back.
Taking in that I am passing bytes and not bits (thanks guys), I came up with this but I have one more request for help. How do I pass the For Loop index to the variable name, as highlighted in the code here?
It isn't complete but I only need advice on this to finish up, I believe.
Also, did I mash in the Message Flag correctly by using the pipe?
int latchPin = 3;
int clockPin = 4;
int dataPin = 5;
//Declare the number portion of the binary arrays
const byte Red0 [3] = {0x80,0x00,0x00};
const byte Red1 [3] = {0x40,0x00,0x00};
const byte Red2 [3] = {0x20,0x00,0x00};
const byte Red3 [3] = {0x10,0x00,0x00};
const byte Red4 [3] = {0x08,0x00,0x00};
const byte Red5 [3] = {0x04,0x00,0x00};
const byte Red6 [3] = {0x02,0x00,0x00};
const byte Red7 [3] = {0x01,0x00,0x00};
const byte Red8 [3] = {0x00,0x80,0x00};
const byte Red9 [3] = {0x00,0x40,0x00};
const byte Blu0 [3] = {0x00,0x20,0x00};
const byte Blu1 [3] = {0x00,0x10,0x00};
const byte Blu2 [3] = {0x00,0x08,0x00};
const byte Blu3 [3] = {0x00,0x04,0x00};
const byte Blu4 [3] = {0x00,0x02,0x00};
const byte Blu5 [3] = {0x00,0x01,0x00};
const byte Blu6 [3] = {0x00,0x00,0x80};
const byte Blu7 [3] = {0x00,0x00,0x40};
const byte Blu8 [3] = {0x00,0x00,0x20};
const byte Blu9 [3] = {0x00,0x00,0x10};
//Negative or Positive?
const byte Neg =0x08;
//Farhenheit or Celcius
const byte Farhenheit = 0x04;
const byte Celc = 0x02;
const byte message = 0x01;
byte tagmessage;
int outdoorTemp= -18;
boolean farh = true;
boolean outdoor=true;
boolean IsMessage = true;
char digit[3];
int firstdigit;
int seconddigit;
int thirddigit;
int t;
void setup()
{
Serial.begin(19200);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop()
{
if (outdoorTemp > 0){
firstdigit = outdoorTemp/100;
if (firstdigit==1){
t =outdoorTemp-100;
}
else{
t=outdoorTemp;
}
seconddigit = t/10;
thirddigit = outdoorTemp/10 % 10;
}
if (IsMessage){
tagmessage = Red1[2] | message;// turn on the last bit by mashing the message flag into the last byte
}
else{
tagmessage= Red1[2];
}
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, Red1[0]);
shiftOut(dataPin, clockPin, LSBFIRST, Red1[1]);
shiftOut(dataPin, clockPin, LSBFIRST, tagmessage);
digitalWrite(latchPin, HIGH);
//}
delay(1000);
/*
if (IsMessage){
for (int i=seconddigit;i<seconddigit+1;i++)
{
tagmessage = Red{???} [2] | message;//*******************
}
}
else
{
tagmessage = Red{???}[2]; *****************************
}
shiftOut(dataPin, clockPin, LSBFIRST, Red1[0]);
shiftOut(dataPin, clockPin, LSBFIRST, Red1[1]);
shiftOut(dataPin, clockPin, LSBFIRST, tagmessage);
digitalWrite(latchPin, HIGH);
delay(1000);
*/
// and so on...
}
I'll solve the negative number garbage in the temperature reading, but I'm stuck here.