From 8883a68165918e95a22a5da53a2dcd55685a980d Mon Sep 17 00:00:00 2001 From: jj97181818 Date: Tue, 22 May 2018 22:13:06 +0800 Subject: [PATCH] fix correctly --- .gitignore | 53 ------------------------------- LICENSE | 9 ------ Objects/LED.hex | 26 ++++++++++++++++ Objects/led.obj | Bin 0 -> 3710 bytes README.md | 3 -- led.c | 81 +++++++++++++++--------------------------------- 6 files changed, 51 insertions(+), 121 deletions(-) delete mode 100644 .gitignore delete mode 100644 LICENSE create mode 100644 Objects/LED.hex create mode 100644 Objects/led.obj delete mode 100644 README.md diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0ee7235..0000000 --- a/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# ---> C -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -modules.order -Module.symvers -Mkfile.old -dkms.conf - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 3f28a5f..0000000 --- a/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Objects/LED.hex b/Objects/LED.hex new file mode 100644 index 0000000..6fba632 --- /dev/null +++ b/Objects/LED.hex @@ -0,0 +1,26 @@ +:04093100C180C101BF +:10088C007590FF120901A2019290120901A2019226 +:10089C0091120901A2019292120901A201929312E2 +:1008AC000901A2019294120901A201929512090167 +:1008BC00A2019296120901A2019297120901A200BB +:1008CC009297120901A2009296120901A200929528 +:1008DC00120901A2009294120901A200929312092A +:1008EC0001A2009292120901A2009291120901A296 +:0508FC00009290808EC7 +:10090100900000AF82AE83E4FCFD7BE87A80F9F8C9 +:09091100D312091B4003A380EA84 +:01091A0022BA +:03000000020800F3 +:0C080000787FE4F6D8FD758120020847DF +:10091B00EB9FF5F0EA9E42F0E99D42F0EC6480C853 +:06092B0064809845F022F3 +:10080C0002088CE493A3F8E493A34003F68001F26E +:10081C0008DFF48029E493A3F85407240CC8C333ED +:10082C00C4540F4420C8834004F456800146F6DFBC +:10083C00E4800B0102040810204080900931E47E12 +:10084C00019360BCA3FF543F30E509541FFEE493B1 +:10085C00A360010ECF54C025E060A840B8E493A378 +:10086C00FAE493A3F8E493A3C8C582C8CAC583CAA3 +:10087C00F0A3C8C582C8CAC583CADFE9DEE780BE5B +:0109350000C1 +:00000001FF diff --git a/Objects/led.obj b/Objects/led.obj new file mode 100644 index 0000000000000000000000000000000000000000..b357acd7ee6326609a0d10195eb0e8e73a5fdacf GIT binary patch literal 3710 zcmaKv-%lJ>6vxlZ&N9odvd~fst?d?y1=_A`%a*pbF6=VERu)!v=?_H5U3LpwC}2U; zUn=R3^r;Q~LHlB~v5AQ<`etGpP4v+x6ZOT^H`8e2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a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# 8051_LED - -微算機作業,控制 LED 燈。 \ No newline at end of file diff --git a/led.c b/led.c index 6a16490..277b5a0 100644 --- a/led.c +++ b/led.c @@ -3,67 +3,36 @@ bit lightoff = 1; bit lighton = 0; -sbit P1_0 = P1^0; -sbit P1_1 = P1^1; -sbit P1_2 = P1^2; -sbit P1_3 = P1^3; -sbit P1_4 = P1^4; -sbit P1_5 = P1^5; -sbit P1_6 = P1^6; -sbit P1_7 = P1^7; + +char code LED_light[17] = { + ~0x00, + ~0x01, + ~0x02, + ~0x04, + ~0x08, + ~0x10, + ~0x20, + ~0x40, + ~0x80, + ~0x40, + ~0x20, + ~0x10, + ~0x08, + ~0x04, + ~0x02, + ~0x01 +}; + void delay_1500ms(); int main () { P1 = 0xFF; - while (1) { + while (1) + // ********* ¹ê§@ LED ********* + for(LED_mode = 0; LED_mode < 16; LED_mode++) { + P1 = LED_light[LED_mode]; + } delay_1500ms(); - - P1_0 = lighton; - delay_1500ms(); - - P1_1 = lighton; - delay_1500ms(); - - P1_2 = lighton; - delay_1500ms(); - - P1_3 = lighton; - delay_1500ms(); - - P1_4 = lighton; - delay_1500ms(); - - P1_5 = lighton; - delay_1500ms(); - - P1_6 = lighton; - delay_1500ms(); - - P1_7 = lighton; - delay_1500ms(); - - P1_7 = lightoff; - delay_1500ms(); - - P1_6 = lightoff; - delay_1500ms(); - - P1_5 = lightoff; - delay_1500ms(); - - P1_4 = lightoff; - delay_1500ms(); - - P1_3 = lightoff; - delay_1500ms(); - - P1_2 = lightoff; - delay_1500ms(); - - P1_1 = lightoff; - delay_1500ms(); - - P1_0 = lightoff; } // end of while(1) } // end of main()