Tham khảo tài liệu ' pic robotics a beginners guide to robotics projects using the pic micro ebook-lib part 5', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | TRISB Decimal 134 86 Hex Port B Port B Decimal 6 06 Hex Binary Power of Two 00000001 2 1 00000010 21 2 00000100 22 4 00001000 23 8 00010000 24 16 00100000 25 32 01000000 26 64 10000000 27 128 Bit Weight Values Register Location Power Binary of Two 00000001 2 1 ------------------------------- 00000010 21 2 00000100 22 4 -------------------------- 00001000 23 8 ---------------------- 00010000 24 16 -------------------- 00100000 25 32 -------------- 01000000 26 64 ---------- 10000000 27 128 Bit Weight Values 128 64 32 16 8 4 2 Register Location I I I Illi RB3 h . CD ỊỌ TJ co CM T- co CD CD CD CD CD CD DC DC DC DC DC DC DC RB0 Figure Diagram of port B registers. 68 Chapter Six port B I O pins. This correspondence between the bit number bit weight and the I O line is used to program and control the port. Using the TRIS and port registers The TRIS tri-state enable register is a 1-byte 8-bit programmable register on the PIC 16F84 that controls whether a particular I O pin is configured as an input or output pin. There is a TRIS register for each port. TRISA controls the I O status for the pins on port A and TRISB controls the I O status for the pins on port B. If one places a binary 0 at a bit location in TRISB for port B the corresponding pin location on port B will become an output pin. If one places a binary 1 at a bit location in the TRISB the corresponding pin on port B becomes an input pin. The TRISB data memory address for port B is 134 or 86h in hex . After port B has been configured using the TRISB register the user can read or write to the port using a port B address decimal number 6 . Here is an example. Suppose we want to make all port B lines output lines. To do so we need to put a binary 0 in each bit position in the TRISB register. So the number we would write into the register is decimal 0. Now all our I O lines are configured as output lines. If we connect an LED to each output line we can see a visual indication of any number we write to port B. If