A quick course in Binary


project #23: displaying an image on an led matrix



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

project #23: displaying an image on an led matrix


In this project we’ll display the image on the matrix shown in Figure 6-23.

Figure 6-23: Layout for our POV display example
We can define each row as a binary number and place these numbers in an array:
byte smile[] = {B00000000, B00000110,
B01000110,
B00000000,
B00011000,
B00000000,
B11000011,
B01111110};
Notice how the 1s in the array resemble the lit LEDs in the layout in Figure 6-23. Our use of binary numbers makes developing an image very easy. By experimenting with MSBFIRST and LSBFIRST in the shiftOut() functions, you can flip each row around, as shown next. We use a for loop at  to display each row in turn:
// Project 23 - Displaying an Image on an LED Matrix
#define DATA 6 // connect to pin 14 on the 74HC595
#define LATCH 8 // connect to pin 12 on the 74HC595 #define CLOCK 10 // connect to pin 11 on the 74HC595
byte smile[] = {B00000000, B00000110, B01000110, B00000000, B00011000,
B00000000, B11000011, B01111110}; int binary[] = {1, 2, 4, 8, 16, 32, 64, 128};
void setup()
{
pinMode(LATCH, OUTPUT); pinMode(CLOCK, OUTPUT); pinMode(DATA, OUTPUT); }
void loop()
{ int i;
 for ( i = 0 ; i < 8 ; i++ )
{
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, ~smile[a]); // columns shiftOut(DATA, CLOCK, LSBFIRST, binary[a]); // rows
digitalWrite(LATCH, HIGH);
delay(1);
}
}
The result is a winking smiley face, as shown in Figure 6-24.

Figure 6-24: Result of Project 23

project #24: Animating an led matrix


Using some bitwise arithmetic, we can scroll the image we created in Project 23 off the display in either direction. For example, to have the face move to the right until its gone, we display the image, then shift each bit in the row over by one using >>, and then display the image again.

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