Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

12f675 programlama

Başlatan tekcarem, 15 Mayıs 2019, 19:07:41

tekcarem

Merhabalar ccs c ile programlama yapmaya çalışyorum.

GP0 Yeşil led
GP1 Tetik ucu
GP2 kırmızı led

olarak devrede tanımlı

tetik ucunda 5v geldiginde kırmızı led 2 saniye yanıp sönecek
5v gelmediginde yeşil led 2 saniye yanıp sönecek


kodlar

#include <a.h>

#fuses INTRC_IO,NOWDT,NOPUT,NOPROTECT,NOCPD,NOMCLR  
 #use delay(clock=4000000)   
 #define GP0 PIN_A0   
 #define GP1 PIN_A1   
 #define GP2 PIN_A2   
 #define GP3 PIN_A3   
 #define GP4 PIN_A4   
 #define GP5 PIN_A5   
 

 void init()   
 {   
 //set_tris_a( 0b00000010 ); // set GP1 input, all other output
 set_tris_a(0b001100); //GP0,1,4,5 output; 2,3 input 

 setup_comparator( NC_NC_NC_NC ); // disable comparators   
 setup_adc_ports( NO_ANALOGS ); // disable analog inputs   
 setup_adc( ADC_OFF ); // disable A2D   

 }   
 main()   
 {   
 
 init();   
 
 //koşul oluştur
 

    
 if (!input(GP1) == 1) 
 {
    
   output_high( GP0 ); // turn LED on   
    delay_ms( 250 ); // wait 250ms   
   output_low( GP0 ); // turn LED off   
   delay_ms( 250 ); // wait 250ms 
  

 } 
 
 if (!input(GP1) == 0)  {
  output_high( GP2 ); // turn LED on   
   delay_ms( 250 ); // wait 250ms   
    output_low( GP2 ); // turn LED off   
   delay_ms( 250 ); // wait 250ms 
 }
 
 }   

m.ak

tris ayarın set_tris_a(0b00010);şeklinde olmalı tris değeri atayabilmek için  #use fast_io(a) satırını #define satırından sonra ilave etmelisin