A quick course in Binary



Download 2,72 Mb.
bet13/17
Sana03.07.2022
Hajmi2,72 Mb.
#736533
1   ...   9   10   11   12   13   14   15   16   17
Bog'liq
6 bo`lim

Making the Connections


Make the connections between the shift registers and the LED matrix (don’t forget the resistors between the output pins of the shift register, which controls the matrix rows, and the matrix row pins), as shown in Table 6-3.

Now to get the matrix working. The shift register marked “rows” in
Figure 6-19 allows current to flow into each row of the matrix, and the “columns” shift register allows current to flow from each of the columns of the matrix to GND. We’ll use a simple sketch to test the setup in the next project. To turn on an LED, we need to control the matching row and column pins of the shift registers.

Bitwise Arithmetic


We can use bitwise arithmetic to manipulate integer and byte variables using their binary representations. The value in using bitwise arithmetic, rather than base-10 arithmetic, is that bitwise can help increase the speed of controlling digital input and output pins and can compare numbers in binary form.
There are six bitwise operators: AND, OR, XOR, NOT, bitshift left, and bitshift right. Each is discussed in the following sections. (Although these examples use binary numbers, the same operations could be performed using integers and bytes.)

The Bitwise AND Operator


The AND operator (&) is used to compare two binary numbers bit by bit. If the bits in the same column of both numbers are 1, then the resulting value’s bit is set to 1; if the bits are not 1, then the result is set to 0. Consider, for example, these 3-byte variables:
byte a = B00110011; byte b = B01010001; byte c = 0;
The result of the comparison

will be 00010001. Expanding this result in a text-comment diagram can show this in more detail:
byte a = B00110011; // |||||||| byte b = B01010001; // ||||||||
// 00010001 c = a & b; // c is equal to a 'AND'ed with b

The Bitwise OR Operator


The OR operator (|) compares two binary numbers, but instead of returning a 1 if both numbers in a column are 1, it returns a 1 if either value in the column is 1. If both numbers in a column are 0, then 0 is returned.
Using the same demonstration bytes as before,
byte a = B00110011; byte b = B01010001; byte c = 0;
the result of the comparison

will be 01110011.

Download 2,72 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   17




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish