|
1 |
| -rem |
2 |
| -rem Hardware Setup: |
3 |
| -rem Power Supply: Connect VCC of the 1088AS to a suitable power supply voltage (usually 5V). |
4 |
| -rem Ground Connection: Connect GND of the 1088AS to the ground (GND) of the IOIO-OTG board. |
5 |
| -rem Data Connections: |
6 |
| -rem Connect the DIN pin of the 1088AS to a digital output pin on the IOIO-OTG board. |
7 |
| -rem Connect the CS pin of the 1088AS to another digital output pin on the IOIO-OTG board. |
8 |
| -rem Connect the CLK pin of the 1088AS to yet another digital output pin on the IOIO-OTG board. |
9 |
| -rem |
10 |
| -rem In the context of an LED matrix display like the 8x8 Duinotech 1088AS, |
11 |
| -rem writing to the DIN (Data Input) pin is not directly addressing a |
12 |
| -rem particular LED. Instead, it's part of a process to send data to the |
13 |
| -rem display to control which LEDs are lit up. |
14 |
| -rem |
15 |
| -rem Here's a simplified overview of how it works: |
16 |
| -rem |
17 |
| -rem Data Shifted In: You send a stream of data serially to the |
18 |
| -rem display. Each bit of data represents whether a corresponding LED |
19 |
| -rem should be on or off. |
20 |
| -rem |
21 |
| -rem Data Shifted Out to LEDs: As the data is shifted into the display |
22 |
| -rem through the DIN pin, it is internally stored in shift registers. When |
23 |
| -rem enough data is received (for example, 8 bits for an 8x8 LED matrix), |
24 |
| -rem the display will update the LEDs accordingly. |
25 |
| -rem |
26 |
| -rem Control Signals: Alongside the data, you typically send control |
27 |
| -rem signals like clock pulses (CLK) to synchronize the shifting of data |
28 |
| -rem and chip select (CS) to indicate when the data is valid. |
29 |
| -rem |
30 |
| -rem Matrix Multiplexing: The LED matrix is typically arranged in rows and |
31 |
| -rem columns. By controlling the state of each row and column (using |
32 |
| -rem additional control pins or internally within the display), you can |
33 |
| -rem select individual LEDs or groups of LEDs to turn on or off. |
34 |
| -rem |
35 |
| -rem Updating Display: After sending the necessary data and control |
36 |
| -rem signals, the display refreshes itself to reflect the new state of the |
37 |
| -rem LEDs based on the received data. |
38 |
| -rem |
39 |
| -rem So, when you write to the DIN pin, you're not directly addressing a |
40 |
| -rem particular LED. Instead, you're sending data to the display to update |
41 |
| -rem the entire matrix, and by controlling the row and column pins, you |
42 |
| -rem indirectly address specific LEDs or groups of LEDs within the matrix. |
43 |
| -rem |
44 |
| - |
45 | 1 | import ioio
|
46 | 2 |
|
47 |
| -const dinPin = 2 |
| 3 | +const mosiPin = 2 |
| 4 | +const misoPin = 6 |
48 | 5 | const csPin = 3
|
49 | 6 | const clkPin = 4
|
50 | 7 |
|
51 |
| -din = ioio.openDigitalOutput(dinPin) |
| 8 | +spi = ioio.openSpiMaster(misoPin, mosiPin, sckPin, csPin) |
52 | 9 | cs = ioio.openDigitalOutput(csPin)
|
53 |
| -clk = ioio.openDigitalOutput(clkPin) |
54 | 10 |
|
55 | 11 | ioio.waitForConnect(10)
|
56 | 12 |
|
57 |
| -while 1 |
58 |
| - shiftOut(0x55) |
59 |
| - delay 10000 |
60 |
| -wend |
| 13 | +rem true sets the initial state to high (deasserted) |
| 14 | +cs.write(true) |
61 | 15 |
|
62 |
| -sub shiftOut(_data) |
63 |
| - cs.write(false); ' Enable the chip |
64 |
| - for i = 7 to 0 step -1 |
65 |
| - clk.write(false) ' Start clock pulse |
66 |
| - din.write((_data band (1 lshift i)) != 0) ' Send bit |
67 |
| - clk.write(true) ' End clock pulse |
| 16 | +spi.write(0x09, 0x00) ' Decode mode: no decode for digits 0-7 |
| 17 | +spi.write(0x0A, 0x07) ' Intensity: maximum intensity 0x0 -> 0x0F |
| 18 | +spi.write(0x0B, 0x07) ' Scan limit: all digits |
| 19 | +spi.write(0x0C, 0x01) ' Shutdown: normal operation |
| 20 | + |
| 21 | +while 1 |
| 22 | + for i = 1 to 8 |
| 23 | + spi.write(0x55) |
68 | 24 | next
|
69 |
| - cs.write(true) ' Disable the chip |
70 |
| -end |
| 25 | + delay 1000 |
| 26 | +wend |
| 27 | +' |
0 commit comments