Pages: [1]   Go Down
Author Topic: trying to understand custom characters and the 8_bit format[SOLVED]  (Read 92 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello arduino community , i love you guys!
well when we want to create custom characters we create an array of 7 bytes (or 8 bytes) . all of them start with letter B , for example
Code:
0B00000
well i understand what the digits on the right of the letter B are for , but not the letter B itself and the zero to its left , i dont understand what they mean and why we put them there . also i found a converter from character to byte code and the conversion did not give me no letter B , so is it something specific to the arduino  language ?
« Last Edit: July 20, 2014, 06:41:33 pm by abdallah_bukhari » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4245
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
well i understand what the digits on the right of the letter B are for , but not the letter B itself and the zero to its left
The initial zero is there to inform the compiler that this is a number.
The 'B' tells the compiler that this is a 'Binary' number.


Don
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 517
Posts: 26287
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There are 3 common ways to show data:
1) show each bit individually, BIN format
0b01011010 or B01011010, shows bit 7 on the left (MSB) and 0 on the right (LSB)

2) show the data in HEX format
0x5A (0101 is 5, 1010 is A).
0b00000000 = 0x00
0b00000001 = 0x01
0b00000010 = 0x02
0b00000011 = 0x03
0b00000100 = 0x04
0b00000101 = 0x05
0b00000110 = 0x06
0b00000111 = 0x07
0b00001000 = 0x08
0b00001001 = 0x09
0b00001010 = 0x0A
0b00001011 = 0x0B
0b00001100 = 0x0C
0b00001101 = 0x0D
0b00001110 = 0x0E
0b00001111 = 0x0F

3) show the data in Decimal format
0x00 thru 0x0F = 0 to 15
0x00 thru 0xFF = 0 to 255

Depending on what you are doing, one format  might be better over another.
When designing hardware, I often think in binary terms to make it easier to visualize bit placement.
Same for HEX - when looking at data coming from devices, manipulating it to combine nibbles (1/2 upper or lower 4 bits in a byte),  it can be easier to see the data in HEX format.

Decimal - 0 to 255 just doesn't tell you much about the data.

The compiler will give you errors if you have too many binary bits, or not enough hex digits.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Online Online
Sr. Member
****
Karma: 14
Posts: 452
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Reference/IntegerConstants
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 517
Posts: 26287
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What's this have to do with "crystal library library"?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you guys
Logged

Pages: [1]   Go Up
Jump to: