A quick course in Binary



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

The Sketch


Here’s the sketch for our animation demonstration:
// Project 24 - Animating 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 a, hold, shift;
 for ( shift = 0 ; shift < 9 ; shift++ )
{  for ( hold = 0 ; hold < 25 ; hold++ )
{
for ( a = 0 ; a < 8 ; a++ )
{
digitalWrite(LATCH, LOW);
 shiftOut(DATA, CLOCK, MSBFIRST, ~smile[a]>>shift); // columns shiftOut(DATA, CLOCK, LSBFIRST, binary[a]); // rows
digitalWrite(LATCH, HIGH);
delay(1);
}
}
}
}
The sketch holds the image on the matrix for 25 display cycles using a for loop at . The variable shift is the amount by which each byte will shift to the right. After each loop has completed, the variable shift is increased by 1 as shown at . Next, the display cycles repeat, and the image moves to the right by one LED column. By changing MSBFIRST to LSBFIRST in the third for loop at , we can change the direction that the face scrolls.

looking Ahead


In this chapter you have learned a lot of fundamental skills that will be used over and over in your own projects. LED displays are relatively hardy, so enjoy experimenting with them and making various display effects. However, there is a limit to what can be displayed, so in the next chapter we make use of much more detailed display methods for text and graphics.


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