Dear all.
I have sample code below.FAULT_PISO is variable which hold value of serial out. I could able to get Serial output from device .
I wanted to use the bit value of variable how can i do in it.
for example FAULT_PISO=0X10
then i wanted to read 8 bit of FAULT_PISO value. 1000 0000 in this i wanna access 8 bit value which i wanted to use for comparing with enum value.
if enum value is == FAULT_PISO_8bit
led =on
else
led =off
int PISO_CLK = 3 ; // Output its clock input for 74hc765 connected to PIN2
int PISO_FAULT = 4; // Serial I/p (Q7) Connected to PIN 9 of 74HC765
int PISO_PL_EN = 5; // Load input for Connected to PIN 1 of 74HC765
unsigned char PISO_CLK_EN = 0;
unsigned char byteValue = 0;
unsigned char bitValue;
volatile unsigned char FAULT_PISO;
void CHK_FAULT_INPUT(void) {
unsigned char i;
byteValue = 0; // accumulates image of 8 switches
bitValue = 0;
PISO_PL_EN = 0; // latch data
delayMicroseconds(200);
PISO_PL_EN = 1; //ADD
delayMicroseconds(200);
for (i = 0; i < 8; i++) {
bitValue = PISO_FAULT;
byteValue |= (bitValue << ((8 - 1) - i));
PISO_CLK = 1;
delayMicroseconds(200);
PISO_CLK = 0;
delayMicroseconds(200);
}
FAULT_PISO = byteValue;
Serial.print("FAULT_PISO:");
Serial.println(FAULT_PISO);
}
void setup()
{
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
CHK_FAULT_INPUT();
delay(1000);
}