บทความ

mikro c 6

รูปภาพ
 ใบรายงานผลการปฏิบัติงาน Code PORTB = Hex(s%10); PORTD.F2 = 1; Delay_ms(10); PORTD.F2 = 0; PORTB = Hex((s/10)%10); PORTD.F1 = 1; Delay_ms(10); PORTD.F1 = 0; PORTB = Hex((s/100)%10); PORTD.F0 = 1; Delay_ms(10); PORTD.F0 = 0; unsigned int Hex(int a) { switch(a) { case 1: return 0x06; case 2: return 0x5B; case 3: return 0x4F; case 4: return 0x66; case 5: return 0x6D; case 6: return 0x7D; case 7: return 0x07; case 8: return 0x7F; case 9: return 0x6F; case 0: return 0x3F; } } ภาพจำลองการทำงานด้วยโปรแกรม Proteus อ้างอิง https://electrosome.com/matrix-keypad-pic-microcontroller/

mikro c5

รูปภาพ
   ใบรายงานผลการปฏิบัติงาน Code char readKeyboard() { unsigned int i = 0; for(i=0;i<4;i++) { if(i == 0) PORTB = 1; else if(i == 1) PORTB = 2; else if(i == 2) PORTB = 4; else if(i == 3) PORTB = 8; if(PORTB.F4) return findKey(i,0); if(PORTB.F5) return findKey(i,1); if(PORTB.F6) return findKey(i,2); if(PORTB.F7) return findKey(i,3); } return ' '; } char findKey(unsigned short a, unsigned short b) { if(b == 0) { if(a == 3) return '0'; else if(a == 2) return '1'; else if(a == 1) return '2'; else if(a == 0) return '3'; } else if(b == 1) { if(a == 3) return '4'; else if(a == 2) return '5'; else if(a == 1) return '6'; else if(a == 0) return '7'; } else if(b == 2) { if(a == 3) return '8'; else if(a == 2) return '9'; else if(a == 1) return 'A'; else if(a == 0) r...

mikro c 4

รูปภาพ
    ใบรายงานผลการปฏิบัติงาน Code sbit LCD_RS at RB4_bit ; sbit LCD_EN at RB5_bit ; sbit LCD_D4 at RB0_bit ; sbit LCD_D5 at RB1_bit ; sbit LCD_D6 at RB2_bit ; sbit LCD_D7 at RB3_bit ;   sbit LCD_RS_Direction at TRISB4_bit ; sbit LCD_EN_Direction at TRISB5_bit ; sbit LCD_D4_Direction at TRISB0_bit ; sbit LCD_D5_Direction at TRISB1_bit ; sbit LCD_D6_Direction at TRISB2_bit ; sbit LCD_D7_Direction at TRISB3_bit ; unsigned int adcvalue , value , temp_res ; unsigned char car , x , y ; char * voltage = "00.00" ; long temp ;   // Routine to show the value of the ADC_read void ShowADC ( int x , int y , unsigned int adcvalue ) { car = adcvalue / 1000 ; LCD_Chr ( x , y , 48 + car ) ; adcvalue = adcvalue - 1000 * car ; car = ( adcvalue / 100 ) ; LCD_Chr_CP ( 48 + car ) ; adcvalue = adcvalue - 100 * car ; car = ( adcvalue / 10 ) ; LCD_Chr_CP ( 48 + car ) ; adcvalue = adcvalue - 10 * car ; car = adcvalue ; LCD_Chr_CP ( 48 + c...

mikro c 3

รูปภาพ
                 ใบรายงานผลการปฏิบัติงาน Code unsigned int i; unsigned int duty_50; void main(){ ADPCFG = 0xFFFF; // initialize AN pins as digital PORTB = 0xAAAA; TRISB = 0; // initialize portb as output Delay_ms(1000); duty_50 = PWM1_MC_Init(5000, 0, 0x01, 0); // Pwm_Mc_Init returns 50% of the duty PWM1_MC_Set_Duty(i = duty_50, 1); PWM1_MC_Start(); do { i--; PWM1_MC_Set_Duty(i, 1); Delay_ms(10); if (i == 0) i = duty_50 * 2 - 1; // Let us not allow the overflow PORTB = i; } while(1); ภาพจำลองการทำงานด้วยโปรแกรม Proteus อ้างอิง http://download.mikroe.com/documents/compilers/mikroc/dspic/help/pwm_motor_library.htm

mikro c 2

รูปภาพ
    ใบรายงานผลการปฏิบัติงาน Code void main() { TRISB.F0 = 0; //Makes PORTB0 or RB0 Output Pin while(1) //Infinite Loop { PORTB.F0 = 1; //LED ON Delay_ms(1000); //1 Second Delay PORTB.F0 = 0; //LED OFF Delay_ms(1000); //1 Second Delay } } ภาพจำลองการทำงานด้วยโปรแกรม Proteus vอ้างอิง https://electrosome.com/led-blinking-pic/

mikro c 1

รูปภาพ
              ใบรายงานผลการปฏิบัติงาน Code // LCD module connections sbit LCD_RS at RC2_bit; sbit LCD_EN at RC3_bit; sbit LCD_D4 at RC4_bit; sbit LCD_D5 at RC5_bit; sbit LCD_D6 at RC6_bit; sbit LCD_D7 at RC7_bit; sbit LCD_RS_Direction at TRISC2_bit; sbit LCD_EN_Direction at TRISC3_bit; sbit LCD_D4_Direction at TRISC4_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC6_bit; sbit LCD_D7_Direction at TRISC7_bit; // End LCD module connections void main() { Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,"Hello World");//Write text'Hello World' in first row } ภาพจำลองการทำงานด้วยโปรแกรม Proteus อ้างอิง https://electrosome.com/lcd-pic-interfacing/

arduino 16

รูปภาพ
              ใบรายงานผลการปฏิบัติงาน Code #include <Stepper.h>     //  การอ่านไฟล์จากไดเร็กทอรี หรือโฟลเดอร์ที่กำหนดไว้ #include "Keypad.h"  #define STEP_ANGLE_4STEP 32 //360/11.25 degree    //    ใช้เพื่อตั้งชื่อค่าคงที่ #define STEP_OUT_WITH_GEAR 2048 //32*64 Stepper stepper(STEP_ANGLE_4STEP,8,10,9,11); char keys[4][4]={    // เก็บข้อมูลที่  หน่วยความจำ  1  ไบต์   {'7','8','9','A'},   {'4','5','6','B'},   {'1','2','3','C'},   {'*','0','#','D'}}; byte rowPins[] = {7,6,5,4}; byte colPins[] = {3,2,1,0}; int speedmotor = 400;    / /  ตัวแปรพื้นฐานที่เก็บตัวเลขโดยไม่มีจุดทศนิยม int dirmotor = 1; Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,4,4); //ฟังก์ของkeypad void setup()      //  ฟังก์ชั่นใช้ในการประกาศค่าเริ่มต้น   { } void loop()   //  ฟังก์ชั่นใช้ในการเขียนโค้ดโปรแกรมการทำงานของ...