Hello, and greetings from Germany.
Me and a friend of mine are having troubles solving a problem with a particular given code for our final Test in Electronics.
In January we are electronics technicians-to-be and not Programmers, and for the function of our connected circuit we want to understand how the program works in order to get a deeper understanding of what our circuit will do when applied.
Here is one part of the code that we struggle with:
digitalWrite(D1, (BestZelle&0x0001)>>0); digitalWrite(D2, (BestZelle&0x0002)>>1); digitalWrite(D3, (BestZelle&0x0004)>>2); digitalWrite(D4, (BestZelle&0x0008)>>3); digitalWrite(D5, (BestZelle&0x0010)>>4); digitalWrite(D6, (BestZelle&0x0020)>>5); digitalWrite(D7, (BestZelle&0x0040)>>6); digitalWrite(D8, (BestZelle&0x0080)>>7);
Beforehand, "BestZelle" is not defined as an integer, which we don't understand. But, regardless of that we thought "BestZelle" should be within the range of 0 to 4 (decimal) or 1 to 4 (decimal).
We don't know why the result of the comparison of "BestZelle" and "0x00**" is bitshifted to the right. In our understanding, the result of "digitalWrite" just can be HIGH or LOW. Thats is what leads our heads to an instant burn-out. :stuck_out_tongue_closed_eyes:
We apologize in any circumstances for our lack of knowledge, but we have enough to do with operational amplifiers and the Exam preparation.
In advance, thank you very much for your help!
Marcus and Janos. =)