![]()
Member Since:
23 August 2008
Posts: 687
Points: 627
This post was awarded 1 point!
Ok I need a bit of help understanding this. When you define ports and stuff you will say; PORTB=0xFF and then you see arrays set up using: 0b00101100 is the 0b different because it uses bits instead of letters? thanks
Member Since:
23 October 2007
Posts: 1817
Points: 128
![]()
Member Since:
23 August 2008
Posts: 687
Points: 627
This post was awarded 2 points!
Sorry, in C. Here is the sample i found: #include
Member Since:
14 October 2007
Posts: 520
Points: 242
This post was awarded 2 points!
The language is obviously C for either AVR or PIC PORTD = 0xd7; is hexdecimal code PORTD = 0b11010111; is the exact same number (215), but in hexdecimal form instead. The two are generally interchangeable in code, but it generally pays to use one convention ----------------- If at first you don't succeed, you must be using Windows.
Member Since:
29 August 2008
Posts: 1794
Points: 908
![]()
Member Since:
15 August 2007
Posts: 441
Points: 586
This post was awarded 1 point!
BTW easy way to convert between the two if you understand them. Each hex placeholder will count to 15 decimal (0-9-F) which is equal to a nibble (four bits). To convert binary to hex, break the binary into four block chunks and find what each represents. For example, 916... 1110010100 (Binary) 0011 1001 0100 (Split Binary) 3 9 4 (Decimal Equivalent, and Hex in this case) Of course, if you have a decimal equivalent in the range 10 to 15 then you assign an approprite character, A to F. 255, or 1111 1111, is FF (written as 0xFF under most circumstances) in hex. 256 is 100 in hex. Conversely, you can take each hex character and convert it back to binary. Tom
Member Since:
23 October 2007
Posts: 1817
Points: 128
Member Since:
29 August 2008
Posts: 1794
Points: 908
Member Since:
28 July 2003
Posts: 382
Points: 12
![]()
Member Since:
17 May 2005
Posts: 1991
Points: 1767
This post was awarded 1 point!
binary is handy if you forget the decimal value for some things, eg on my eight digit 7 segment display each segment can be turned on or off via binary codes each digit taking an 8 bit byte to control each binary digit is worth 2^x eg 8 bits 2^8 = 256 or 128 64 32 16 8 4 2 1 in each space from 0 - 11111111 a picaxe can use a byte variable to control output pins using a let pins command with a byte variable eg on an 08 or 08M you can count to 0 to 15 in binary in other words 0x... would be hex 0b... would be binary http://resistorhelper.no-ip.orgYou need to be a member to post.
