Thông báo

Collapse
No announcement yet.

mọi người giúp em cái này với !!!

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • mọi người giúp em cái này với !!!

    em đang làm cái đồ án về giao tếp máy tính dùng vdk 8051
    trên mô phỏng thì chạy vù vù ,em test trên test board thì ko chạy
    mong anh em chỉ giúp dum`..tại em gần nộp bài rồi..hic

    đây là keil C và mạch của em
    #include<at89x52.h>
    #include<stdio.h>
    unsigned char ch;
    int i,j;
    void setup()
    {
    TMOD=0x20;
    TH1=-3;
    //TL1=0xfd;
    PCON=0;
    SCON=0x50;
    TR1=1;

    //TI=0;
    //RI=0;
    IE=0x90 ;
    }

    void nhan(void) interrupt 4
    {
    if(RI)
    {
    ch=SBUF;
    RI=0;
    //if(ch==0x61||ch=='a')P1=0;
    if(ch==0x61) P1=0;
    }
    }


    void delay(unsigned int x)
    {
    for(i=0;i<x;i++)
    for(j=0;j<20;j++);
    }
    void main()
    {
    setup();
    P2_6=0;

    while(1)
    {

    if(ch==0x61)
    {
    P1=0xfe;
    P2_6=0;
    delay(200);
    P2_6=1;
    delay(50);
    }
    if(ch==0x62)
    {

    P1=0xfc;
    P2_6=0;
    delay(150);
    P2_6=1;
    delay(100);
    }
    if(ch==0x63)
    {
    P1=0xf8;
    P2_6=0;
    delay(50);
    P2_6=1;
    delay(200);
    if(ch==0x64)
    {
    P1=0xff;
    P2_6=0;
    }
    }
    }
    }
    **day là code C#:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace fan
    {
    public partial class main : Form
    {
    public main()
    {
    InitializeComponent();
    }

    private void main_Load(object sender, EventArgs e)
    {
    if (serialPort1.IsOpen) serialPort1.Close();
    serialPort1.Open();

    }

    private void main_FormClosed(object sender, FormClosedEventArgs e)
    {
    if (serialPort1.IsOpen) serialPort1.Close();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    serialPort1.Write("a");
    }

    private void button2_Click(object sender, EventArgs e)
    {
    serialPort1.Write("b");
    }

    private void button3_Click(object sender, EventArgs e)
    {
    serialPort1.Write("c");
    }

    private void button4_Click(object sender, EventArgs e)
    {
    serialPort1.Write("d");
    }
    }
    }
    ** và đây là mạch :
    Click image for larger version

Name:	untitled_zps19f8b80e.png
Views:	1
Size:	368.7 KB
ID:	1419821

Về tác giả

Collapse

longbh93 Tìm hiểu thêm về longbh93

Bài viết mới nhất

Collapse

Đang tải...
X