25 Kasım 2021 Perşembe

C# ile pic kontrol ccs compiler

 C# ile pic kontrol ccs c kodları ve devre şeması, c# tasarımı yaptıktan sonra kod ekranına tüm kodları silip alttaki kodları yapıştırın. daha sonra derleme işlemi yapınız. c# tasarım form ekranında 2 buton bir combox bir texbox ekleyiniz. boud hızlarını eşit ayarlayalım standard 9600 kullanılıyor. takıldığını yerde sorabilirisniz.

#include <12f683.h>    

#fuses NOWDT,INTRC_IO,NOMCLR,BROWNOUT

#use delay (clock=4000000) 

#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stop=1)

#use fast_io(a)

int x;

void main ( )

{

   set_tris_a(0x00);

   output_a(0x00); 

   while(true)   

   {

   x=getc();

   if(x=='1')

   {

   output_high(pin_a4);

   x=0;

   }

   if(x=='0')

   {

   output_low(pin_a4);

   x=0;

   }

   }

}

------------------

c# kodları ve program ekranı

sing System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.IO.Ports;

namespace WindowsFormsApp2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            string[] ports = SerialPort.GetPortNames();

            foreach (string port in ports)

            {

                comboBox1.Items.Add(port);

            }

        }

        private void button2_Click(object sender, EventArgs e)

        {

            string t = comboBox1.Text.ToString();

            string s = textBox1.Text.ToString();

            sErial(t, s);

        }

        void sErial(string Port_name, string data_send)

        {

            SerialPort sp = new SerialPort(Port_name, 9600, Parity.None, 8, StopBits.One);

            sp.Open();

            sp.Write(data_send);

            sp.Close();

        }

        private void label2_Click(object sender, EventArgs e)

        {

        }

    }

}







Hiç yorum yok:

Yorum Gönder

Her yorum bilgidir. Araştırmaya devam...