Sensor readings Center Right Center (Where black strip is located) C:\Code\Python\readOptical\src>python readoptical.py sensor _in = 0xff action1 = 0x0 action2 = 0x0 sensorValue1 = 0x0 sensorValue2 = 0x0 0xff & 0xf00 0xff = 0b0000000011111111 0xf00 = 0b0000111100000000 if 0xff & 0xf00 == 0 inside if sensor_in & 0xf00 == 0 0xff & 0xff sensorValue1 = 0b0000000011111111 & 0b0000000011111111 ------------------ 0b0000000011111111 sensorValue1 = 0xff inside of sensorValue1 == 0xff 0x0 | 0x01 action1 = 0b0000000000000000 | 0b0000000000000001 ------------------ 0b0000000000000001 action1 = 0x1 inside of sensorValue2 == 0x00 0x1 | 0x02 action1 = 0b0000000000000001 | 0b0000000000000010 ------------------ 0b0000000000000011 action1 = 0x3 go forward sensor _in = 0x100 action1 = 0x3 action2 = 0x3 sensorValue1 = 0xff sensorValue2 = 0x0 0x100 & 0xf00 0x100 = 0b0000000100000000 0xf00 = 0b0000111100000000 if 0x100 & 0xf00 == 0 inside elif 0x100 & 0xff sensorValue2 = 0b0000000100000000 & 0b0000000011111111 ------------------ 0b0000000000000000 SensorValue2 = 0x0 inside of sensorValue1 == 0xff 0x3 | 0x01 action1 = 0b0000000000000011 | 0b0000000000000001 ------------------ 0b0000000000000011 action1 = 0x3 inside of sensorValue2 == 0x00 0x3 | 0x02 action1 = 0b0000000000000011 | 0b0000000000000010 ------------------ 0b0000000000000011 action1 = 0x3 sensor _in = 0xff action1 = 0x3 action2 = 0x3 sensorValue1 = 0xff sensorValue2 = 0x0 0xff & 0xf00 0xff = 0b0000000011111111 0xf00 = 0b0000111100000000 if 0xff & 0xf00 == 0 inside if sensor_in & 0xf00 == 0 0xff & 0xff sensorValue1 = 0b0000000011111111 & 0b0000000011111111 ------------------ 0b0000000011111111 sensorValue1 = 0xff inside of sensorValue1 == 0xff 0x3 | 0x01 action1 = 0b0000000000000011 | 0b0000000000000001 ------------------ 0b0000000000000011 action1 = 0x3 inside of sensorValue2 == 0x00 0x3 | 0x02 action1 = 0b0000000000000011 | 0b0000000000000010 ------------------ 0b0000000000000011 action1 = 0x3 sensor _in = 0x1ff action1 = 0x3 action2 = 0x3 sensorValue1 = 0xff sensorValue2 = 0x0 0x1ff & 0xf00 0x1ff = 0b0000000111111111 0xf00 = 0b0000111100000000 if 0x1ff & 0xf00 == 0 inside elif 0x1ff & 0xff sensorValue2 = 0b0000000111111111 & 0b0000000011111111 ------------------ 0b0000000011111111 SensorValue2 = 0xff inside of sensorValue1 == 0xff 0x3 | 0x01 action1 = 0b0000000000000011 | 0b0000000000000001 ------------------ 0b0000000000000011 action1 = 0x3 inside of sensorValue2 == 0xff 0x3 & 0xfd action1 = 0b0000000000000011 & 0b0000000011111101 ------------------ 0b0000000000000001 action1 = 0x1 turn left sensor _in = 0xff action1 = 0x1 action2 = 0x1 sensorValue1 = 0xff sensorValue2 = 0xff 0xff & 0xf00 0xff = 0b0000000011111111 0xf00 = 0b0000111100000000 if 0xff & 0xf00 == 0 inside if sensor_in & 0xf00 == 0 0xff & 0xff sensorValue1 = 0b0000000011111111 & 0b0000000011111111 ------------------ 0b0000000011111111 sensorValue1 = 0xff inside of sensorValue1 == 0xff 0x1 | 0x01 action1 = 0b0000000000000001 | 0b0000000000000001 ------------------ 0b0000000000000001 action1 = 0x1 inside of sensorValue2 == 0xff 0x1 & 0xfd action1 = 0b0000000000000001 & 0b0000000011111101 ------------------ 0b0000000000000001 action1 = 0x1 sensor _in = 0x100 action1 = 0x1 action2 = 0x1 sensorValue1 = 0xff sensorValue2 = 0xff 0x100 & 0xf00 0x100 = 0b0000000100000000 0xf00 = 0b0000111100000000 if 0x100 & 0xf00 == 0 inside elif 0x100 & 0xff sensorValue2 = 0b0000000100000000 & 0b0000000011111111 ------------------ 0b0000000000000000 SensorValue2 = 0x0 inside of sensorValue1 == 0xff 0x1 | 0x01 action1 = 0b0000000000000001 | 0b0000000000000001 ------------------ 0b0000000000000001 action1 = 0x1 inside of sensorValue2 == 0x00 0x1 | 0x02 action1 = 0b0000000000000001 | 0b0000000000000010 ------------------ 0b0000000000000011 action1 = 0x3 go forward C:\Code\Python\readOptical\src>