วันพุธที่ 8 มกราคม พ.ศ. 2563

LCD

#define sw_1 PORTB.F0
void main()
{
     char display ;
     char display1 ;
     display   = "55";
     display1  = "66";
     TRISA=0xFF;
     TRISC=0;
     TRISB=0xFF;
     Lcd_Init(&PORTC);
     Lcd_Cmd(LCD_CLEAR);
     Lcd_Cmd(LCD_CURSOR_OFF);
     while(1)
     {      if(sw_1==0)
          {
             Lcd_Cmd(LCD_CLEAR);
             Lcd_Out(1,1,"display") ;
             Lcd_Out(2,1,display);
             delay_ms(500);
             }
            else if (sw_1==1)
            {
             Lcd_Cmd(LCD_CLEAR);
             Lcd_Out(1,1,"555555555") ;
             Lcd_Out(2,1,display1);
             delay_ms(500);
             }
                else{}
             }
     }

2 Motor 4 way

#define sw_1 PORTC.F1
#define sw_2 PORTC.F2
#define sw_3 PORTC.F3
#define sw_4 PORTC.F4
#define mo_1 PORTB.F7
#define mo_2 PORTB.F6
#define mo_3 PORTB.F3
#define mo_4 PORTB.F2

void main()
{
     TRISC=0xFF;
     TRISB=0;
     mo_1=0;mo_2=0;
     mo_3=0;mo_4=0;
     while(1)
     {
           if(!sw_1&sw_2)
           {
                  mo_1=1;mo_2=0;
           }
           else if(sw_1&!sw_2)
           {
                  mo_1=0;mo_2=1;
           }
           else if  (!sw_3&sw_4)
            {
                 mo_3=1;mo_4=0;
             }
            if  (sw_3&!sw_4)
             {
                  mo_3=0;mo_4=1;
                  }

            else  mo_1=0;mo_2=0;
                  mo_3=0;mo_4=0;

     }
}

7 segment cc2 digit

#define digit1 PORTB.F6
#define digit2 PORTB.F7

void main()
{
     TRISB=0;
     TRISC=0;
     while(1)
     {
             digit1=1;
             digit2=0;
             PORTC=~0x06;
             delay_ms(50);
             digit1=0;
             digit2=1;
             PORTC=~0x07;
             delay_ms(50);
      }
}

LED ดับทั้ง 2 ดวง

#define sw1 PORTB.F2
#define sw2 PORTB.F6
#define LED_YELLOW PORTC.F0
#define LED_GREEN PORTC.F1

void main()
{
TRISB=0xFF;
TRISC=0;
PORTC=0;
while(1)
{
if(sw1==0)
{
LED_YELLOW=1;
if(sw2==0)LED_GREEN=1;
else LED_GREEN=0;
}
else if(sw2==0)LED_GREEN=1;
else
{
LED_YELLOW=0;
LED_GREEN=0;
}
}
}

งานที่2

 เกลียว ชนิดและส่วนต่างๆของเกลียว เกลียว ( Thread)  หมายถึงสันหรือร่องที่เกิดขึ้นบนผิวงานวนไปรอบ ๆจะซ้ายหรือขวาก็ไดด้วยระยะทางที่สม่ำเสมอ เ...