کد اصلاح شده:
کد:# 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 ); }


1 لایک
LinkBack URL
About LinkBacks



پاسخ با نقل قول