/******************************************************************* * hc165_and_grayscale Read the value of 8-channel grayscale module - Due to the lack of IO, the car uses two 3-to-8 io expansion chips HC165 to connect two IR obstacle avoidance modules and one 8-channel grayscale module - Two IR obstacle avoidance modules use the lower two io The 8-channel grayscale module uses the high 8-bit io ******************************************************************/ #include #include "hc165.h" void setup() { Serial.begin(115200); gsBegin(); } void loop() { byte data = gsRead(); /* A certain light of the module is on, the corresponding io becomes low level, and the bit value is 0 */ Serial.print("data: "); for(int i = 7;i>=0;i--){ if(data & (1<> 8 & 0xFF; }