アップロードチャンネル










●多機能マイコン PICシリーズの機能

[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

マイクロチップ〓 PICマイコン〓PIC16F88-I/P
価格:385円(税込、送料別) (2021/2/22時点)


●PIC-16F87

電源電圧:4.0〜5.5V
・コアサイズ:8bit
・命令長:14bit
・クロック:20MHz
・プログラムメモリ:4kW
・EEPROM:256B
・RAM:368B
・GPIO:16pin
・UART/USART:1Ch
・I2C:1Ch
・SPI:1Ch
・タイマ:3Ch
・オシレータ:内蔵/外付

掲載コードの動作は、PIC18f13k22は、XC8で確認した。

このサイトでは、PIC18F13K22かPIC16F87を推薦する。

PICは、専用のROMライターでないとプログラムの書き込みは、出来ない。
専用のソフト MPLAB-Xを使用して使う。




PIC16F87/88

●PIC16f87のテストコード 




LEDを点灯させるテストコード


// PIC16F87 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF      // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital I/O, MCLR internally tied to VDD)
#pragma config BOREN = OFF      // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = ON         // Low-Voltage Programming Enable bit (RB3/PGM pin has PGM function, Low-Voltage Programming enabled)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB0      // CCP1 Pin Selection bit (CCP1 function on RB0)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

// CONFIG2
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF       // Internal External Switchover bit (Internal External Switchover mode disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#define _XTAL_FREQ 8000000
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
         int set;
        
        unsigned int ax[100];
        unsigned int bx[100];
        unsigned int ac[300][5];
        unsigned int ai[10][10];
    }*sys;
    


void main( void )
{
   sys p;
     p->set=0;
     
     
    unsigned int i,j,k,m;
    float f=0;
   char fc[30][3];
   
   double s[4] ={ 0};
   
    OSCCON = 0b01110000;
   
    PORTA = 0x00;
    PORTB = 0x00;
    TRISA = 0b00000000;
    TRISB = 0b00000000;
   
   
   
   
   
  
    while(1){   
        
          for(i=0; i<300; i++){
              for(j=0; j<3; j++){
                 p->ac[i][j]=rand()%2;
                f =fx1(p->ac[i][j],p->ac[i][j+1],p->ac[i][j+2]);
                if(f<=0){k=0;}
                else{k=1;}
                RB4 = k;
        __delay_ms(10); 
       
       
              if (k!=1) {
             
               PORTA ^= 0b10000011;
               PORTB ^= 0b11100000;
            
             
             __delay_ms(10);
              
              PORTA = 0b00000000;
              PORTB = 0b00000000;
               __delay_ms(10);
             }
              else {PORTA ^= 0b00000011;__delay_ms(10);
              
              PORTA = 0b00000000;
               __delay_ms(10);
              }
               
                s[0]=xor(p->ac[i][j],p->ac[i][j+1]+p->ac[i][j+2]);
                 
       if(s[0]!=0){PORTA ^= 0b10000011;__delay_ms(10);}
       
       if (s[0]!=1){ PORTA ^= 0b00000011;
               PORTB ^= 0b11000000;__delay_ms(10);}
       
       
       
      
              
             
              }
              
         
         
         }
    }    
       
        
    
}











●PIC12f683のテストコード 機械学習ぽいコード

[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

マイクロチップ〓 PICマイコン〓PIC12F675-I/P
価格:154円(税込、送料別) (2021/2/22時点)





LEDを機械学習ぽい感じで点灯するテストコード
コードも機械学習を再現したぽいコード


// PIC12F683 Configuration Bit Settings

// 'C' source line config statements

// CONFIG
#pragma config FOSC = INTOSCIO  // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF      // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON       // Brown Out Detect (BOR enabled)
#pragma config IESO = OFF       // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#define _XTAL_FREQ 8000000
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
float fx1(int x, int y ,int z);
void life( int y);
  
typedef struct {
         int set;
        char a[30][3];
        char b[30][3];
        unsigned int ax[101];
         unsigned int bx[101];
        unsigned int ac[300][3];
        unsigned int ai[10][10];
    }*sys; // 容量これ以上は、エラー
    
 float fx1(int x, int y ,int z) {
 unsigned int i,j,k,m;
 float ax=0;
 ax=(x+y+z)-1.5;
 
 if (ax<=0){ax=0;}
 
 
 return ax;
 }  
 void life( int y)
{
	int i;
    int set=0;
	sys p;
     
	for (i = 0; i < 101; i++) {
			
			p->ax[i] = rand() % 2;
			
			
set = 4 * p->ax[i - 1] + 2 * p->ax[i] + 1 * p->ax[i + 1];

			if (set) { p->ax[i + 2] = set; }

				else if (p->ax[i+2] == 7) { p->ax[i+2] = 0; }
				else if (p->ax[i+2] == 6) { p->ax[i+2] = 0; }
				else if (p->ax[i+2] == 5) { p->ax[i+2] = 0; }
				else if (p->ax[i+2] == 4) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 3) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 2) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 1) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 0) { p->ax[i+2] = 0; }
				
			

				if (p->ax[100] > -1) {
					p->ax[0] = p->ax[100];
				}
				else if (p->ax[1] > -1) {
					p->ax[101] = p->ax[1];
				}

				p->bx[i] = p->ax[i];

			if (p->bx[i] == 1) { p->bx[i] = 1; }
			else{ p->bx[i] = 0; }
                if(p->bx[i]!=0){GPIO ^= 0b00100001;__delay_ms(30);}



		
	}
	
	
 }
void main() {
    unsigned int i,j,k;
    float f=0;
    // 容量これ以上は、エラー
    
    
OSCCON =0b01110000;    // 内蔵クロックの周波数を8MHzに設定 内臓オシレータ bit4-6 周波数
ANSEL = 0b00000000;  //アナログ入力デジタル入力切り替え
CMCON0 = 0x07;// コンパレータ無効化
TRISIO = 0b0001000; //ピンのモード(入出力)0=出力 1=入力 GP3=1

sys p;
     
     
while(1)
{ 
    for(i=0; i<300; i++){
              for(j=0; j<3; j++){
                 p->ac[i][j]=rand()%2;
                f =fx1(p->ac[i][j],p->ac[i][j+1],p->ac[i][j+2]);
                if(f!=1){GPIO = 0b00110000;}
                if(f!=0){GPIO = 0b00000111;}
               
         __delay_ms(30);
        
                 }//for2
        
        life(1); __delay_ms(30);
              }
          
   

}
  
    
    
    
}







●PIC12f1840のテストコード 




LEDを機械学習ぽい感じで点灯するテストコード
コードも機械学習を再現したぽいコード


// PIC12F1840 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF      // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = ON         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = OFF       // Internal/External Switchover (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)

// CONFIG2
#pragma config WRT = ALL        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON      // PLL Enable (4x PLL disabled)
#pragma config STVREN = OFF     // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will not cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON         // Low-Voltage Programming Enable (Low-voltage programming enabled)
#define _XTAL_FREQ 32000000
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
float fx1(int x, int y ,int z);
int life( int y);
  double xor(double x, double y);
  double not(double x, double y);
 
  double nand(double x, double y);
 
typedef struct {
         int set;
       
        unsigned int ax[101];
         unsigned int bx[101];
        unsigned int ac[300][5];
        unsigned int ai[101][101];
    }*sys; 
    
 float fx1(int x, int y ,int z) {
 unsigned int i,j,k,m;
 float ax=0;
 ax=(x+y+z)-1.5;
 
 if (ax<=0){ax=0;}
 
 
 return ax;
 }  
 double xor(double x, double y)
{

	return nand(nand(nand(x, y), y), nand(x, nand(x, y)));
}
double not(double x, double y)
{

	return nand(nand(x, y), nand(x, y));


}



double nand(double x, double y)
{
	if (1 < x) { x = 1; }
	if (1 < y) { y = 1; }
	if (x <= -1) { x = 0; }
	if (y <= -1) { y = 0; }
	double z = 0;
	z = (-2)* x + (-2)* y + 3;



	if (-1 >= z) { z = 0; }
	if (1 <= z) { z = 1; }

	return z;

}



 int life( int y)
{
	int i;
    int set=0;
	sys p;
     
	for (i = 0; i < 101; i++) {
			
			p->ax[i] = rand() % 2;
			
			
set = 4 * p->ax[i - 1] + 2 * p->ax[i] + 1 * p->ax[i + 1];

			if (set) { p->ax[i + 2] = set; }

				else if (p->ax[i+2] == 7) { p->ax[i+2] = 0; }
				else if (p->ax[i+2] == 6) { p->ax[i+2] = 0; }
				else if (p->ax[i+2] == 5) { p->ax[i+2] = 0; }
				else if (p->ax[i+2] == 4) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 3) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 2) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 1) { p->ax[i+2] = 1; }
				else if (p->ax[i+2] == 0) { p->ax[i+2] = 0; }
				
			

				if (p->ax[100] > -1) {
					p->ax[0] = p->ax[100];
				}
				else if (p->ax[1] > -1) {
					p->ax[101] = p->ax[1];
				}

				p->bx[i] = p->ax[i];

			if (p->bx[i] == 1) { p->bx[i] = 1; }
			else{ p->bx[i] = 0; }
                RA0=p->bx[i];



		
	}
	return 0;
	
 }
void main() {
     unsigned int i,j,k;
     double s[4]={0};
    float f=0;
    sys p;
     
    
     OSCCON = 0b01110000;
    ANSELA = 0b00000000;
    TRISA  = 0b00000000;
    PORTA  = 0b00000000;
    
    
    while(1){
        
         for(i=0; i<300; i++){
              for(j=0; j<3; j++){
                 p->ac[i][j]=rand()%2;
                f =fx1(p->ac[i][j],p->ac[i][j+1],p->ac[i][j+2]);
                if(f<=0){f=0;}
                else{f=1;}
                RA0 = f;
         __delay_ms(30);
    s[0]=xor(p->ac[i][j],p->ac[i][j+1]+p->ac[i][j+2]);
    
    s[1]=not(p->ac[i][j],p->ac[i][j+1]+p->ac[i][j+2]);
     s[2]=nand(p->ac[i][j],p->ac[i][j+1]+p->ac[i][j+2]);
     
       if(s[0]!=0){PORTA ^= 0b00110110;__delay_ms(10);}
       
    else if (s[0]!=1){ PORTA ^= 0b00000001;__delay_ms(10);}
    if(s[1]!=0){PORTA ^= 0b00010010;__delay_ms(10);}
       
    else if (s[1]!=1){ PORTA ^= 0b00000001;__delay_ms(10);}
     if(s[2]!=0){PORTA ^= 0b00010110;__delay_ms(10);}
       
    else if (s[2]!=1){ PORTA ^= 0b00000001;__delay_ms(10);}
     
        
   
                 }//for2
        
        
              }
           life(1);
    }

}
  



●PIC18f13k22のテストコード 



[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

ASOOVU USB
価格:2728円(税込、送料別) (2021/2/22時点)






ランダムLED点灯 IO RB7LED RB6 LED  2個のLEDのみ



* File:   newmain.c
 * Author: post_000
 *
 * Created on 2018/10/06, 19:21
 */

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>


#include <stdio.h>
#include <stdlib.h>
// CONFIG1H
#pragma config FOSC = IRC       // Oscillator Selection bits (External RC oscillator)
#pragma config PLLEN = ON      // 4 X PLL Enable bit (PLL is under software control)
#pragma config PCLKEN = ON      // Primary Clock Enable bit (Primary clock enabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

// CONFIG2L
#pragma config PWRTEN = ON     // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 30        // Brown Out Reset Voltage bits (VBOR set to 1.9 V nominal)

// CONFIG2H
#pragma config WDTEN = OFF       // Watchdog Timer Enable bit (WDT is always enabled. SWDTEN bit has no effect.)
#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config HFOFST = ON      // HFINTOSC Fast Start-up bit (HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.)
#pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled, RA3 input pin disabled)

// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config BBSIZ = OFF      // Boot Block Size Select bit (512W boot block size)
#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 not code-protected)
#pragma config CP1 = OFF        // Code Protection bit (Block 1 not code-protected)

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block not code-protected)
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 not write-protected)
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 not write-protected)

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block not protected from table reads executed in other blocks)



#define _XTAL_FREQ 1600000
/*
 * 
 */int fx1(float x);
  
typedef struct {
         int set;
        
        unsigned int ax[10];
        unsigned int bx[10];
         int ac[30][3];
         int ad[30][3];
    }*sys;
    
 int fx1(float x ) {
 unsigned int i,j,k,m;
 double ax=0;
 srand(x);
__delay_ms(10);
 ax=(float)rand() / RAND_MAX;
 
 if (ax<0.51){m=1; }
else m=0;
 
 
 return m;
 }  
 
  

int main(int argc, char** argv) {
    
     
     
      
     
     int i,j,k,m,l;
    float f=0;
    float t=0;
   
      
   
    ADCON0 = 0x2F;//ADコンバーター設定
    ADCON1 = 0x2C;//AD  Positive Voltage Reference select bit
    ADCON2 = 0x03;//AD 動作周波数指定
    OSCCON = 0b01110010;    // 内蔵クロックの周波数を16MHzに設定
    PORTA = 0x00;           // PORTAを初期化 出力設定
    PORTB = 0x00;           // PORTBを初期化 出力設定
 
    TRISA = 0x00;           // PORTAの入出力設定
    TRISB = 0b00100000;           // PORTB の入出力設定 AN11(RB5)アナログ入力
  
     ANSELH = 0b00001000;//ADコンバーター上位ピン指定
     ANSEL = 0x00;//ADコンバーター ピン指定
   
   
   
   
   sys p;
     p->set=0;
     
    while(1){ 
        
        for(i=0; i<30; i++){
              for(j=0; j<3; j++){
                  
                
                 
                 p->ac[i][j]=fx1( TRISB = 0x20);
                 
                 
             p->ad[i][j]=fx1(TRISB = 0x20);
               
               if(p->ac[i][j]==1){
                 PORTB=0x80;
               __delay_ms(100);}
                else  PORTB=0x00;__delay_ms(100);
         if(p->ad[i][j]==1){
                  PORTB=0x40;
               __delay_ms(100);
              } else  PORTB=0x00;__delay_ms(100);
        
        
              }
          }
 
 
        
       
        
        
        
    }
       
      
         


}




[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

P-Star 25K50 マイクロプログラマブルモジュール
価格:1233円(税込、送料別) (2021/2/22時点)



●PIC18f13k22のアノード7セグ 1個の点灯実験のコード 





アノード7セグメントLED1個の点灯 0〜9まで

A-RB4
B-RB5
C-RB6
D-RB7
E-RC7
F-RC6
G-RC4

Comon-RC3 or vcc

カソードの場合 COMON RC3=0 or GND

RB4からRC4まで=0
void off( ){TRISB = 0x00; TRISC = 0x00;__delay_ms(500);TRISB = 0xFF;  TRISC = 0xFF; }  に変更 



/* 
 * File:   newmain.c
 * Author: post_000
 *
 * Created on 2018/10/06, 19:21
 */

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>


#include <stdio.h>
#include <stdlib.h>
// CONFIG1H
#pragma config FOSC = IRC       // Oscillator Selection bits (External RC oscillator)
#pragma config PLLEN = ON      // 4 X PLL Enable bit (PLL is under software control)
#pragma config PCLKEN = ON      // Primary Clock Enable bit (Primary clock enabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

// CONFIG2L
#pragma config PWRTEN = ON     // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 30        // Brown Out Reset Voltage bits (VBOR set to 1.9 V nominal)

// CONFIG2H
#pragma config WDTEN = OFF       // Watchdog Timer Enable bit (WDT is always enabled. SWDTEN bit has no effect.)
#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config HFOFST = ON      // HFINTOSC Fast Start-up bit (HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.)
#pragma config MCLRE = OFF       // MCLR Pin Enable bit (MCLR pin enabled, RA3 input pin disabled)

// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config BBSIZ = OFF      // Boot Block Size Select bit (512W boot block size)
#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 not code-protected)
#pragma config CP1 = OFF        // Code Protection bit (Block 1 not code-protected)

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block not code-protected)
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 not write-protected)
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 not write-protected)

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block not protected from table reads executed in other blocks)



#define _XTAL_FREQ 16000000
/*
 * 
 */
  
typedef struct {
         int set;
        
         
         int ac[10][10];
         int ad[10][10];
         //未使用
    }*sys;
    
void fx0( ) {
  int i,j,k,m;
  
  RC3=1;
   RB4 = 0;RB5=0;RB6=0;RB7=0;
   RC4=1;RC6=0;RC7=0;
  
  __delay_ms(500);
 
 }  
void fx1( ) { 
    int i,k;
  char bx[2]={0x08,0x40};
   RC3=1;
  RB4=1;RB5=1;RB6=1;RB7=1;
  RC4 =1;RC6=0;RC7=0;
  
  __delay_ms(500);
    
}
 void fx2( ) { 
    int i,k;
    
 
   RC3=1;
  RB4=0;RB5=0;RB6=1;RB7=0;
  RC7=0;RC6=1;RC4=0;
    __delay_ms(500);
    
} 
 void fx3( ) { 
    int i,k;
  
   RC3=1;
  RB4=0;RB5=0;RB6=0;RB7=0;
  RC7=1;RC6=1;RC4=0;
  
    __delay_ms(500);
} 
 void fx4( ) { 
    int i,k;
 
  RC3=1;
  RB4=1;RB5=0;RB6=0;RB7=1;
  RC7=1;RC6=0;RC4=0;
  
    __delay_ms(500);
} 
void fx5( ) { 
    int i,k;
 
 RC3=1;
 RB4=0;RB5=1;RB6=0;RB7=0;
 RC7=1;RC6=0;RC4=0;
  
    __delay_ms(500);
} 
void fx6( ) { 
    int i,k;
 
  RC3=1;
   RB4=0;RB5=1;RB6=0;RB7=0;
   RC7=0;RC6=0;RC4=0;
  
    __delay_ms(500);
} 
void fx7( ) { 
    int i,k;
 
 RC3=1;
  RB4=0;RB5=0;RB6=0;RB7=1;
  RC7=1;RC6=0;RC4=1;
    
  __delay_ms(500);
} 
void fx8( ) { 
    int i,k;
 
  RC3=1;
  RB4=0;RB5=0;RB6=0;RB7=0;
  RC7=0;RC6=0;RC4=0;
  __delay_ms(500);
    
} 
void fx9( ) { 
    int i,k;
  
 
  RC3=1;
  RB4=0;RB5=0;RB6=0;RB7=1;
  RC7=1;RC6=0;RC4=0;
  
    __delay_ms(500);
} 
void off( ) {
  int i,j,k,m;
 
 TRISB = 0xFF;// PORTB の出力停止
 TRISC = 0xFF;__delay_ms(500);// PORTC の出力停止
 TRISB = 0x00;    // PORTB の出力       
 TRISC = 0x00;   // PORTC の出力
 
 

  
  
 
 }  
int main(int argc, char** argv) {
    
     
     
      
     
     int i,j,k,m,l;
     
    float f=0;
    float t=0;
   
      
   
    
    OSCCON = 0x72;    // 内蔵クロックの周波数を16MHzに設定
    PORTA = 0x00;           // PORTAを初期化 出力設定
    PORTB = 0x00;           // PORTBを初期化 出力設定
    PORTC = 0x00;
    TRISA = 0x00;           // PORTAの入力設定
    TRISB = 0x00;           // PORTB の入出力設定 
    TRISC = 0x00;
     ANSELH = 0b00000000;//ADコンバーター上位ピン指定
     ANSEL = 0x00;//ADコンバーター ピン指定
   
   
   
   
   sys p;
     p->set=0;
     
    while(1){
   
             
             fx0();
             off( );
             fx1();
             off( );
             fx2();
             off( );
             fx3();
             off( );
             fx4();
             off( );
             fx5();
             off( );
             fx6();
             off( );
             fx7();
             off( );
             fx8();
             off( );
             fx9();
             off( );
    
            
    
    
    }
        
       
               
            
              
             
             
    
       
        
}   






7seg
[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

東芝〓7セグメント数字表示素子〓TLS337T
価格:33円(税込、送料別) (2021/3/17時点)












Powered by FC2ホームページ


inserted by FC2 system