نمایش نتایج: از 1 به 9 از 9
Like Tree1 لایک
  • 1 Post By

موضوع: ماژول سون سگمنت 8 رقمی دارای درایور tm1638 و 8 کلید کنترلی

Hybrid View

  1. #1
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    کد آردوینو :

    کد:
    # include  <TM1638.h>
    
    
    // Set pin numbers for connection to Arduino 
    # define DATA 2 
    # define CLOCK 3 
    # define STROBE 4
    
    
    // Create an instance from the Library panel TM1638
    TM1638 panel (DATA, CLOCK STROBE);
    
    
    void  setup () {
       // communications through the serial port at 9600 baud 
      Serial . begin ( 9600 );
    }
    
    
    void  loop () {
       // create a variable to hold the status button 
      // in pure form (panelTlac) and to an extent 1-8 (button) 
      byte panelTlac panel.getButtons = ();
       int Button = 0 ;
       // create a variable time and storing 
      // the current time from activation Arduino 
      // seconds 
      long time = millis () / 1000 ;
       // LED switched on with a button 
      // working for multiple buttons at once 
      panel.setLEDs (((panelTlac & 0xF0 ) << 8 ) | (panelTlac & 0xF ));
       // to light the LEDs used this command and example: 
      // setLED (0 for off / 1 to turn on), the number of LED 
      /// panel.setLED (1, 4); // Turn on the fourth LED
    
    
      // Translation pure forms of the extent of 1-8 
      switch (panelTlac) {
         case  1 :
          Button = 1 ;
           break ;
         case  2 :
          Button = 2 ;
           break ;
          case  4 :
          Button = 3 ;
           break ;
         case  8 :
          Button = 4 ;
           break ;
          case  16 :
          Button = 5 ;
           break ;
         case  32 :
          Button = 6 ;
           break ;
          case  64 :
          Button = 7 ;
           break ;
         case  128 :
          Button = 8 ;
           break ;
         default :
          Button = 0 ;
      }
      // If the button has been pressed, 
      // write down his number over the serial line 
      // and write out a sample screen character 
      if (Button> 0 ) {
         Serial . Print ( "pressing the button" );
         Serial . Println (button) ;
         // extract samples of the characters in hex format 
        // 1 means a dot in the first digit 
        panel.setDisplayToHexNumber ( 0x1234ABCD , 1 );
      }
      // If no buttons are pressed, 
      // prints to display the current time from the launch 
      else {
         // statement numbers in the format: number, dot with the second character, 
        // 0 for listing without zeros / 1 listing with zeros 
        panel.setDisplayToDecNumber (cas , 2 , 0 );
      }
      // Pause for a clearer statement 
      delay ( 500 );
    }


    کتابخانه ضمیمه شده است.
    رفرنس:
    http://navody.arduino-shop.cz/navody-k-produktum/ovladaci-panel-tm1638.html
    فایل های پیوست شده فایل های پیوست شده

  2. #2
    Junior Member
    تاریخ عضویت
    Dec 2016
    نوشته ها
    9
    کد اصلاح شده:

    کد:
    # include  <TM1638.h>
    
    
    // Set pin numbers for connection to Arduino 
    # define DATA 2 
    # define CLOCK 3 
    # define STROBE 4
    
    
    // Create an instance from the Library panel TM1638
    TM1638 panel (DATA, CLOCK, STROBE);
    
    
    void  setup () {
                    // communications through the serial port at 9600 baud 
                    Serial . begin ( 9600 );
                    }
    
    
    void  loop () {
       // create a variable to hold the status button 
      // in pure form (panelTlac) and to an extent 1-8 (button) 
      
      byte panelTlac = panel.getButtons();
       int Button = 0 ;
       // create a variable time and storing 
      // the current time from activation Arduino 
      // seconds 
      long time = millis () / 1000 ;
       // LED switched on with a button 
      // working for multiple buttons at once 
      panel.setLEDs (((panelTlac & 0xF0 ) << 8 ) | (panelTlac & 0xF ));
       // to light the LEDs used this command and example: 
      // setLED (0 for off / 1 to turn on), the number of LED 
      /// panel.setLED (1, 4); // Turn on the fourth LED
    
    
      // Translation pure forms of the extent of 1-8 
      switch (panelTlac) {
         case  1 :
          Button = 1 ;
           break ;
         case  2 :
          Button = 2 ;
           break ;
          case  4 :
          Button = 3 ;
           break ;
         case  8 :
          Button = 4 ;
           break ;
          case  16 :
          Button = 5 ;
           break ;
         case  32 :
          Button = 6 ;
           break ;
          case  64 :
          Button = 7 ;
           break ;
         case  128 :
          Button = 8 ;
           break ;
         default :
          Button = 0 ;
      }
      // If the button has been pressed, 
      // write down his number over the serial line 
      // and write out a sample screen character 
      if (Button> 0 ) {
         Serial.print("pressing the button");
         Serial.println(Button) ;
         // extract samples of the characters in hex format 
        // 1 means a dot in the first digit 
        panel.setDisplayToHexNumber ( 0x1234ABCD , 1 );
      }
      // If no buttons are pressed, 
      // prints to display the current time from the launch 
      else {
         // statement numbers in the format: number, dot with the second character, 
        // 0 for listing without zeros / 1 listing with zeros 
        panel.setDisplayToDecNumber(time, 2, 0);
      }
      // Pause for a clearer statement 
      delay ( 500 );
    }

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO