如何打开点矩阵74HC595上具有特定地址的LED?

时间:2018-07-23 02:48:55

标签: c raspberry-pi led circuit

我想确定点矩阵8x8 74HC595中每个LED的地址时遇到问题,我试图仅点亮一个带有该地址的LED。我已经尝试了许多教程和文档,但是仍然运气不好,只能在1个特殊位置的LED上点亮。

这是我的电路设计: https://www.sunfounder.com/learn/Super_Kit_V2_for_RaspberryPi/lesson-12-driving-dot-matrix-by-74hc595-super-kit-for-raspberrypi.html

我的C代码:

#include <wiringPi.h>
#include <stdio.h>

#define   SDI   0   //serial data input
#define   RCLK  1   //memory clock input
#define   SRCLK 2   //shift register clock input

unsigned char LED[8] ={0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

void pulse(int pin)
{
    digitalWrite(pin, 0);
    digitalWrite(pin, 1);
}

void ShiftOUT(unsigned char byte)
{
    int i;

    for(i=0;i<8;i++)
    {
        // char a = byte & (0x80 >> i)) > 0;
        digitalWrite(SDI, (( byte & (0x80 >> i)) > 0));
        printf("%d", (( byte >> i > 0)));
        pulse(SRCLK);
    }


    printf("\n","==================");
}

void init(void)
{
    pinMode(SDI, OUTPUT);
    pinMode(RCLK, OUTPUT);
    pinMode(SRCLK, OUTPUT);
    digitalWrite(SDI, 0);
    digitalWrite(RCLK, 0);
    digitalWrite(SRCLK, 0);
}

int main(void)
{
    int i;

    if(wiringPiSetup() == -1)
    {
        printf("setup wiringPi failed !");
        return 1;
    }

    init();

    while(1)
    {
         for(i=0;i<8;i++)
         {

            ShiftOUT(LED[i]);
            pulse(RCLK);
            // printf("=======pull latch========");
            // printf("\n");
            delay(150);
         }


        delay(500);


   }

    return 0;
}

我尝试过的此代码将点亮1行,我想点亮1个特殊位置的LED

这是我用来模拟指向LED的链接:https://www.riyas.org/2013/12/online-led-matrix-font-generator-with.html

有帮助吗?谢谢

0 个答案:

没有答案