Beispiel 2

Dependencies:   NeoPixel mbed

Fork of Nucleo_neopixel_ovgu1 by Rita Freudenberg

Committer:
Hinz
Date:
Mon Dec 11 12:55:19 2017 +0000
Revision:
4:1f676d6961e8
Parent:
2:08c13f9a3d5c
Child:
5:0993d55a871e
ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:028fac66239d 1 #include "mbed.h"
Hinz 4:1f676d6961e8 2 #include "neopixel.h"
Hinz 4:1f676d6961e8 3
Hinz 4:1f676d6961e8 4 NeoPixel npx(D6,8);
bcostm 1:e9d1c42a73ae 5
Hinz 4:1f676d6961e8 6 void setByte(uint8_t bits, uint32_t color)
Hinz 4:1f676d6961e8 7 {
Hinz 4:1f676d6961e8 8 for (int i=0; i<8; i++)
Hinz 4:1f676d6961e8 9 if (bits & 1 << i)
Hinz 4:1f676d6961e8 10 npx.setColor(i,color);
Hinz 4:1f676d6961e8 11 else
Hinz 4:1f676d6961e8 12 npx.setColor(i,0);
Hinz 4:1f676d6961e8 13 npx.show();
Hinz 4:1f676d6961e8 14 }
bcostm 1:e9d1c42a73ae 15
bcostm 2:08c13f9a3d5c 16
bcostm 2:08c13f9a3d5c 17
Hinz 4:1f676d6961e8 18 int main() {
Hinz 4:1f676d6961e8 19 int i;
Hinz 4:1f676d6961e8 20
Hinz 4:1f676d6961e8 21 for (i=0; i<8; i++)
Hinz 4:1f676d6961e8 22 npx.setColor(i,0x00ff00);
Hinz 4:1f676d6961e8 23 npx.show();
Hinz 4:1f676d6961e8 24 wait(5.0);
Hinz 4:1f676d6961e8 25
Hinz 4:1f676d6961e8 26 npx.setColor(0,0xff0000);
Hinz 4:1f676d6961e8 27 npx.setColor(1,0x00ff00);
Hinz 4:1f676d6961e8 28 npx.setColor(2,0x0000ff);
Hinz 4:1f676d6961e8 29 npx.setColor(3,0xffff00);
Hinz 4:1f676d6961e8 30 npx.setColor(4,0x00ffff);
Hinz 4:1f676d6961e8 31 npx.setColor(5,0xff00ff);
Hinz 4:1f676d6961e8 32 npx.setColor(6,0xffffff);
Hinz 4:1f676d6961e8 33 npx.setColor(7,0x1f1f1f);
Hinz 4:1f676d6961e8 34 npx.show();
Hinz 4:1f676d6961e8 35 wait(5.0);
Hinz 4:1f676d6961e8 36
Hinz 4:1f676d6961e8 37 char* text = "INFORMATIK";
Hinz 4:1f676d6961e8 38
Hinz 4:1f676d6961e8 39 while(*text) {
Hinz 4:1f676d6961e8 40 setByte(*text++,0xff0000);
Hinz 4:1f676d6961e8 41 wait(1.0);
bcostm 2:08c13f9a3d5c 42 }
Hinz 4:1f676d6961e8 43
Hinz 4:1f676d6961e8 44
bcostm 0:028fac66239d 45 }