您的位置 首页 IC

PIC单片机模仿开关程序

程序介绍:简单的按键按下,相应的灯亮,按键弹起,灯灭。只有一个按键哦,相应的也只是一个灯亮。defineMX_PICDefinesformicroco

程序介绍:简略的按键按下,相应的灯亮,按键弹起,灯灭。只要一个按键哦,相应的也仅仅一个灯亮。

#define MX_P%&&&&&%
//Defines for microcontroller
#define P16F690
#define MX_EE
#define MX_EE_SIZE 256
#define MX_SPI
#define MX_SPI_BCB
#define MX_SPI_SDI 4
#define MX_SPI_SDO 7
#define MX_SPI_SCK 6
#define MX_UART
#define MX_UART_B
#define MX_UART_TX 7
#define MX_UART_RX 5
#define MX_I2C
#define MX_MI2C
#define MX_I2C_B
#define MX_I2C_SDA 4
#define MX_I2C_SCL 6
#define MX_PWM
#define MX_PWM_CNT 1
#define MX_PWM_TRIS1 trisc
#define MX_PWM_1 5
//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include
#endif
#ifdef HI_TECH_C
#include #endif
//Configurationdata
//Internal functions
#include “F:Program FilesMatrix MultimediaFlowcode V4FCDinternals.h”
//Macro function declarations
//Variable declarations
char FCV_COUNT;
//Macro implementations
void main()
{

//Initialisation
ansel = 0;
anselh = 0;

//Interrupt initialisation code
option_reg = 0xC0;
//Loop
//Loop: While 1
while (1)
{
//Input
//Input: A0 -> count
trisa = trisa | 0x01;
FCV_COUNT = ((porta & 0x01) == 0x01);
//Decision
//Decision: count=1?
if (FCV_COUNT==1)
{
//Output
//Output: count -> C0
trisc = trisc & 0xfe;
if (FCV_COUNT)
portc = (portc & 0xfe) | 0x01;
else
portc = portc & 0xfe;
} else {
//Input
//Input: PORT A -> count
trisa = trisa | 0xff;
FCV_COUNT = porta;
//Output
//Output: count -> PORT C
trisc = 0x00;
portc = FCV_COUNT;
}
}
mainendloop: goto mainendloop;
}
void MX_INTERRUPT_MACRO(void)
{
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/318565.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部