z6HnSmwHu

51 MCU stc15w learning board drives ACDC and PC817 isolated input

 
Overview

 //51 single-chip microcomputer stc15w learning board drives AC, drives DC and uses PC817 isolated input. Thanks to LiChuang for sharing it today for those in need.
 
 //Using stc15w204s microcontroller tm1640 chip DIN=P1^0; 15 CLK=P1^1; 16 //CODE[7]=CODE[7] | 10000000;//Display decimal point /***************************************************************************** *Copyright information: Shenzhen Tianwei Electronics Co., Ltd. *File name: TM1640-V1.0 *Current version: V1.0 *MCU model: STC12C5608AD *Development environment: Keil uVision4 *Crystal oscillator frequency: 11.0592MHZ *Completion date: 2013-07-18 *Program function: Digital tube driver: drive 8-segment 16-bit LED common cathode digital tube to display 0123456789AbCdEF; *Disclaimer: 1. This program is a demonstration program for TM1640 driving LED digital tubes and is for reference only. 2. If there is any economic loss caused by directly using this routine program, our company will not bear any responsibility ****************************************************************************/ //Header file #include "intrins.h" //Contains _nop_() instruction Header file #include
 
/********************Define control port**************************/
//Data to be displayed unsigned int temptime=0;//Second calculation unsigned int xsbl;//Data to be displayed/********************Define data****************************/
/********************Delay function, delay nms******************/ void delay_nms(unsigned int n){unsigned int i;while(n--)for(i=0;i<550;i++);}
 
 
void main(){
    P0M0 = 0x00; P0M1 = 0x00; P1M1=0x08;//0000 0000 P1M0=0;//0000 0000
    //Configure P1.0 as push-pull output mode
        P1M1&=0xfc;//1111 1100 P1M0|=0x03;//0000 0011
    P2M0 = 0x00; P2M1 = 0x00; P3M0 = 0xf0; P3M1 = 0x00; P11=0; P10=0;
while(1){
        if (P13 == 0) {delay_nms(100); if (P13 == 0) { P11 = 1; P10 = 1; delay_nms(2000); P11 = 0; P10 = 0; delay_nms(2000);
        }//P10 is pressed and the counter increases by 10 }    
            }}
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-24 11:32:19

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号