Web page control 430 single chip microcomputer[Copy link]
This example uses a web page to control a single-chip microcomputer, realizing the communication between software and hardware. 1. Development Technology Hardware: 430 single-chip microcomputer; Software: jsp, servlet. 2. Development ideas We write our program on the 430 MCU, connect the MCU to the serial port, and control the 430 MCU through the serial port wizard. Then we develop a Java program to control the serial port in the servlet, which is equivalent to the previous serial port wizard. By clicking on different numbers on the web page, it is transmitted to the MCU, and different numbers are used to control the MCU to achieve different effects. 3. The program is as follows 430 microcontroller program[/ color] #include "msp430x14x.h" int a=10; unsigned char j=0x01,j2=0x00; unsigned char j1=0X80,K1=0X01;
void delay(int i)
{
while(i--)
{
for(int j=0;j<125;j++);
}
}
void main( void )
{
WDTCTL = WDTPW + WDTHOLD; //停止看门狗
P2DIR=0xff; //把p2设为输出。
P2OUT=0xff; //把p2设为高电平
P3SEL|=0x30;
P6DIR=0xff;
P6OUT=0xff;
ME1|=UTXE0+URXE0;
UCTL0|=CHAR;
UTCTL0|=SSEL0;
UBR00=0x0D;
UBR10=0x00;
UMCTL0=0x6B;
UCTL0&=~SWRST;
IE1|=URXIE0;
_EINT();
while(1)
{
if(a=='0') //实现流水灯。
{
P2OUT=~j;
j=j<<1;
if(j==0X00)
j=0x01;
for(int i=0;i<10000;i++)
for(int k=0;k<3;k++);
}
if(a=='1') //实现碰撞灯
{
j1=j1>>1;
K1=K1<<1;
if(j1==0x01)
j1=0x80;
if(K1==0x80)
K1=0x01;
P2OUT=~(j1|K1);
for(int i=0;i<10000;i++)
for(int k=0;k<2;k++);
}
if(a=='2') //实现闪光灯
{
j2^=0XFF;
P2OUT=j2;
for(int i=0;i<10000;i++)
for(int k=0;k<2;k++);
}
if(a=='3') //实现蜂鸣器
{
P6OUT^=0xff;
for(int i=0;i<10000;i++)
for(int k=0;k<2;k++);
}
}
}
#pragma vector = UART0RX_VECTOR //中断服务子程序
__interrupt void shen(void)
{
P6OUT=0xff;
a=RXBUF0;
while(!(IFG1&UTXIFG0));
TXBUF0 = a;