//
// Experiment description: LED0 - LED5 flowing water lighting
//
// Notes:
//
//-------------------------------------------------------------------------------------------
#include "pic.h"
__CONFIG(FOSC_HS&WDTE_OFF&LVP_OFF); //External crystal WDT OFF
#define _XTAL_FREQ 8000000L //8MHz crystal
#define LED0 PORTCbits.RC2 //LED macro definition
#define LED1 PORTCbits.RC1
#define LED2 PORTCbits.RC0
#define LED3 PORTAbits.RA5
#define LED4 PORTAbits.RA3
#define LED5 PORTAbits.RA2
//-------------------------------------------------------------------------------
// Main program
//-------------------------------------------------------------------------------
void main(void)
{
ADCON1= 0b11001110; //RA0 for AN0
TRISA = 0b11010011; //RA2 RA3 RA5 output
TRISB = 0b11111100; //RB0 RB1 output
TRISC = 0b11011000; //RC0-RC2 output
LED0 = 1; //LED0-LED5 light up
LED1 = 1;
LED2 = 1;
LED3 = 1;
LED4 = 1;
LED5 = 1;
__delay_ms(800); //delay
LED0 = 0; //LED0-LED5 off
LED1 = 0;
LED2 = 0;
LED3 = 0;
LED4 = 0;
LED5 = 0;
__delay_ms(10); //delaywhile
(1)
{
LED0 = 0; //LED5 light up
LED1 = 0;
LED2 = 0;
LED3 = 0;
LED4 = 0;
LED5 = 1;
__delay_ms(200); //delay
LED0 = 0; //LED4-LED5 light up
LED1 = 0;
LED2 = 0;
LED3 = 0;
LED4 = 1;
LED5 = 1;
__delay_ms(200); //Delay
LED0 = 0; //LED3-LED5 light up
LED1 = 0;
LED2 = 0;
LED3 = 1;
LED4 = 1;
LED5 = 1;
__delay_ms(200); //Delay
LED0 = 0; //LED2-LED5 light up
LED1 = 0;
LED2 = 1;
LED3 = 1;
LED4 = 1;
LED5 = 1;
__delay_ms(200); //Delay
LED0 = 0; //LED1-LED5 light up
LED1 = 1;
LED2 = 1;
LED3 = 1;
LED4 = 1;
LED5 = 1;
__delay_ms(200); //Delay
LED0 = 1; //LED0-LED5 on
LED1 = 1;
LED2 = 1;
LED3 = 1;
LED4 = 1;
LED5 = 1;
__delay_ms(200); //Delay
LED0 = 0; //LED0-LED5 off
LED1 = 0;
LED2 = 0;
LED3 = 0;
LED4 = 0;
LED5 = 0;
__delay_ms(200); //Delay
}
}
//-------------------------------------------------------------------------------
Previous article:HC-SR04 ultrasonic module 51+PIC microcontroller routine
Next article:pic16f877 tm0 makes the LED flash every 10ms
Recommended ReadingLatest update time:2024-11-15 13:47
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- 14. [Learning LPC1768 library functions] DAC experiment
- [Linux Touch Call] If you give up the market, why shouldn’t I grab the territory?
- Sensor Basics
- Basic Concepts of RF Power Amplifier
- PMU Power Management Unit Layout
- Questions and answers about CCS project COFF and ELF output formats
- Request a free ZVS buck regulator evaluation sample!
- [Environmental Expert's Smart Watch] Part 13: Storing various data in EEPROM
- Behavioral modeling sequential logic circuit (two-input AND gate) source code and test code
- Hardware testing method for TI-CC chip