Secondly
i declared the CAN Connection with the same ID in CANdb++ analyzer to send the data that are defined throw CAN communication to Arduino.
The Communication works and Arduino getting the Data succesfully
The Core Problem
The data will be send or recieved in "Byte" from 0 to 7. which mean that the 5 Signals in the first 5 bits that i define it before will be transmitted throw the first byte shown in the followin pic.
As buf [8] contains the 8 Bytes of the data and i need to print 8 bits of each of byte
i writed this code:
The byte array has sequences Links to write [buf(1), buf(2), .....buf(8)]
The Bits sequences is printed mirrored: Example:
if buf(1) = 20 Hex , expected the bits num of [ 0010 0000 ]
but what i actualy becom is [0000 0100]
Question:
How could i arrange this sequences to deal with the signal?
Why do you need to store the bit data in an another array ? You know now how to read the value of the bits of the bytes in an array so you can use those to compare with
// check if bit 2 in variable myByte is 1
if (bitRead(myByte, 2) == 1) {
}
// check if bit 2 in variable myByte is 0
if (bitRead(myByte, 2) == 0) {
}
You can always wait for the next small question to be answered in the forum
or you start learning to fish yourself by writing small testprograms that print to the serial monitor
Be the change you want to see in the world
best regards Stefan