arm7 Litian Electronics lpc2148 GPIO pattern water light

Publisher:lambda21Latest update time:2019-05-14 Source: eefocusKeywords:arm7  lpc2148  GPIO Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The LPC2148 development board of Litian Electronics has four running lights. They are connected to the SN74HC595D and then connected to the 2148 processor. First light up the two on the sides (16, 19), then light up the two in the middle (17, 18). When turning off, turn off the two on the sides first, then the one in the middle. The program is shown in the figure below:


#include


#define SCLK 0x01<<24

#define MISO 0x01<<5

#define MOSI 0x01<<6

#define RCK 0x01<<7

void Delayn(unsigned long n);

void HC595_Init(void);

void Write595(void);

unsigned int HC595_DATA = 0;


//Initialize 595 interface

void HC595_Init(void)

{

  IO0DIR |= MOSI|RCK;

  IO1DIR |= SCLK;

  IO1CLR |= SCLK;

  IO0DIR |= RCK;

  

  HC595_DATA = 0xFFFFFFFF; Write595();

}

//Write bytes

void WriteByte(unsigned char data)

{

  unsigned char i;

  //IO0CLR = RCK;

  for(i=0;i<8;i++)

  {

    if(data&0x01) IO0SET=MOSI;

    else IO0CLR=MOSI;

    IO1SET=SCLK;

    data>>=1;

    IO1CLR=SCLK;

  }

  //IO0SET = RCK;

}

//Refresh 595 data

void Write595(void)

{

  IO0CLR = RCK;

  WriteByte(HC595_DATA&0xff);

  WriteByte((HC595_DATA&0xff00)>>8);

  WriteByte((HC595_DATA&0xff0000)>>16);

  WriteByte((HC595_DATA&0xff000000)>>24);

  IO0SET = RCK;

}

main(void)

{

  // Initialize 74HC595

  HC595_Init();

  

  //Main loop

  while(1)

  {

    HC595_DATA &=~(1<<16);Write595();

    HC595_DATA &=~(1<<19);Write595();

    Delayn(1000000);

    HC595_DATA &=~(1<<17);Write595();

    HC595_DATA &=~(1<<18);Write595();

    Delayn(1000000);

    

    HC595_DATA |=(1<<16);Write595();

    HC595_DATA |=(1<<19);Write595();

    Delayn(1000000);

    HC595_DATA |=(1<<17);Write595();

    HC595_DATA |=(1<<18);Write595();

    Delayn(1000000);  

  }

}

//Delay cycle number

void Delayn(unsigned long n)

{

  while(n--);

}


Keywords:arm7  lpc2148  GPIO Reference address:arm7 Litian Electronics lpc2148 GPIO pattern water light

Previous article:arm7 Litian Electronics lpc2148 GPIO key input test
Next article:arm7 Litian Electronics lpc2148 GPIO 2 single-channel LED control experiment

Recommended ReadingLatest update time:2024-11-16 13:32

Some issues about STM32 GPIO pins
/*  Name: Some issues about STM32 GPIO pins  Description: When I was writing a keyboard scanning program today, I encountered some problems.  Some pins can read the level status, but some pins can not read the status. After an afternoon of modification and a long search, I finally got some clues. Now I will briefly de
[Microcontroller]
ARM7 learning --- key test program (LPC2103 IO0PIN)
Today I have been learning the key test program. It looks very simple. Everyone can use keys. They have been used in many types of microcontrollers. However, I still encountered a problem today, and it took me half a day to debug and find the problem. At first, I didn't know how to use the GPIO of LPC2103. Later, I che
[Microcontroller]
ARM7 microcontroller (learning) - (eight), IIC interface - 01
The previous article is PWM interface~~ Today is IIC~~ It's basically over~~ ~~ It’s really not easy~~ If I am still in the mood, I will try to use LPC2106 to drive AT24C1024~~ If you don't want to do it~~ That’s it~~ School is about to start~~ Hehe~~ Relax yourself~~ ~~ 8. IIC interface 8—(01) Introduction to IIC r
[Microcontroller]
ARM7 microcontroller (learning) - (eight), IIC interface - 01
About STM32GPIO port configuration commands
The following code is taken from the Atomic STM32 Development Guide //Initialize PB5 and PE5 as output ports and enable the clocks of these two ports        void LED_Init(void)   {   GPIO_InitTypeDef GPIO_InitStructure;   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE, ENABLE); //Enable PB, PE
[Microcontroller]
STM8_GPIO push-pull output
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Experimental platform: ST official three-in-one kit  + Hardware: STM8S105S6T6C + Development platform: IAR For STM8 1.10 + Emulator: ST-Link +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[Microcontroller]
STM32 GPIO Application Notes
1                      The input and output pins of STM32 have the following 8 possible configurations: (4 inputs + 2 outputs + 2 multiplexed outputs) ①Floating  input_IN_FLOATING ②With  pull-up input_IPU    ③With  pull-down input_IPD                      ④Analog  input_AIN ⑤Open  drain output_OUT_OD         
[Microcontroller]
Learning STM8 SPI
#define SPI_CS_PORT GPIOC #define SPI_CS_PIN GPIO_PIN_4 #define SPI_CLK_PORT GPIOC #define SPI_CLK_PIN GPIO_PIN_5 #define SPI_MOSI_PORT GPIOC #define SPI_MOSI_PIN GPIO_PIN_6 #define SPI_MISO_PORT GPIOC #define SPI_MISO_PIN GPIO_PIN_7 SPI is the abbreviation of Serial Peripheral Interface, which is a single-master-mu
[Microcontroller]
Micro rapid urine analyzer system based on LPC2148
Project background and feasibility analysis Project name, main content and current progress Discussion of the key technologies and innovations of the project; Discussion on technology maturity and reliability: Project Name: Design of a Micro Rapid Urine Analyzer Based on CCD main content: Existing automated
[Microcontroller]
Micro rapid urine analyzer system based on LPC2148
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号