PIC microcontroller programming (lighting program)

Publisher:asd999dddLatest update time:2020-01-31 Source: eefocusKeywords:PIC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

IO port control


Direction register TRISA~TRISAE            

For example, TRISB=0x00; // 1 is input, 0 is output, so all portB ports are set to output


Data register PORTA~PORTE            

For example, PORTB=0x01; // 1 is set high, 0 is set low, so portB1 is set high and other portB ports are set low



Example: Lighting program

#include


__CONFIG (0x3B31); // PIC microcontroller needs to configure registers, see the manual for details


 void main()


{


   TRISD=0xfe; // Set RD1 port as output


   PORTD=0x01; // Set RD1 port high


  //RD1=1; PORTD is the same as RD


  while(1);


}

Keywords:PIC Reference address:PIC microcontroller programming (lighting program)

Previous article:PIC microcontroller minimum system (physical)
Next article:Serial port reception problems encountered by PIC microcontrollers

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

PIC32 digital tube program example
#include #pragma config JTAGEN =OFF char   Led ={0x42, 0xf3, 0x86, 0xa2, 0x33, 0x2a, 0x0a, 0xf2, 0x02, 0x22, 0x40, 0xf1, 0x84, 0xa0, 0x31, 0x28, 0x08, 0xf0, 0x00, 0x20, 0x1e, 0x0e, 0x0f, 0xbf, 0x23, 0x9b, 0x8b}; //led font library void spiout(char image ,int len) {     int i; PORTClearBits(IOPORT_B, BIT_9);     for
[Microcontroller]
PIC Microcontroller Getting Started Tutorial (IV) - The First Project
1. New construction project 1.1 Menu bar "File" - "New Project" 1.2 "Microchip Embedded" - "Standalone Project" - "Next" 1.3 Enter your MCU model directly in the device column. Here we take PIC12F675 as an example. Enter "PIC12F675" - "Next" 1.4 Select debug header, if any. "None" - "Next" 1.5 Select the burni
[Microcontroller]
PIC Microcontroller Getting Started Tutorial (IV) - The First Project
PIC microcontroller software asynchronous serial port implementation skills
When developing various embedded application systems with single-chip microcomputers, asynchronous serial communication is a communication mode that is often used. In many applications, it is also required to realize multi-channel asynchronous serial communication. Most of the single-chip microcomputers of various manu
[Microcontroller]
PIC microcontroller software asynchronous serial port implementation skills
3. PIC Harmony component installation, project creation and burning
1. MPLAB Harmony 3 Launcher installation 1. Open the integrated development environment and click Tool- Plugins 2. In the pop-up Plugins interface, click Available Plugins, check MPLAB Harmony 3 Launcher, and click Install. 3. Click Next in the pop-up interface 4. Check to accept the license information and
[Microcontroller]
3. PIC Harmony component installation, project creation and burning
9. PIC Series - Output Comparison - Dual Comparison Mode
1. PIC32 Reference Resources PIC32 Family Reference Manual Chinese version Link address: PIC32 Family Reference Manual Chapter 16 Output Compare 2. Introduction to Dual Compare Match Mode  When control bits OCM 2:0 (OCxCON 2:0 ) = 100 or 101, the output compare is configured as • Single output pulse mode • Conti
[Microcontroller]
9. PIC Series - Output Comparison - Dual Comparison Mode
PIC interrupt special instructions
During the debugging of the W660-MODBUS product, I found that the program would work abnormally under occasional circumstances. After nearly a week of tracking, I found that the PIC interrupt had the following two strange characteristics: The interrupt flag should be cleared when the interrupt is just entered. If th
[Microcontroller]
PIC12F617 MCU ADC initialization configuration
#include  pic.h    #include  PIC12F617.h    #include "ADC.h"      /**************************************************************   @beep_;   void Adc_Init(void); //Complete ADC initialization   ADC configuration process:    1: Port setting: analog input without pull-up    TRISIO 5:0 :               1: GPIO
[Microcontroller]
Battery monitoring circuit using PIC12C508 single chip microcomputer
12v Lead Acid batteries used in trucks, cars, RVs and uninterruptible power supplies are usually rated at 12V. This circuit monitors the battery, the charge and discharge curves, gives the current voltage value and predicts the time left until the power supply ends. The voltage of a 12V battery is 13.
[Microcontroller]
Battery monitoring circuit using PIC12C508 single chip microcomputer
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号