ask for help in C language or assembly 100A water advertising lamp, P1 port control 8 lights, P1.0 from the beginning, every 0.2 seconds to add a light, when all the light, then every 0.2 seconds out of a lamp, until all the lights, so. Programming in assembly or C language.Please ensure that the answer is correct!Two can you verify the correctness of each other? I am really a layman
Ha ha, do not understand, do not understand, you should be microcontroller programming it? Or PLC? You should use C++ to simulate the effect of #include<iostream> #include<vector> #include<windows.h> using namespace STD; #define T Sleep (200) int main (cout<<) {"please a number of input light:"; int x=0; cin>>x; vector<char>tmp; for (int a=0; a <x; a++) {tmp.push_back} int ('*'); xx=2; while (XX) {if (xx==2) {for (int a=x-1; a>=0; a--) {tmp[a]='.'; T; system ("CLS"); for (int b=0; b<x; b++) {cout<<tmp[b]<<}} ";} else {for (xx=1; int a=0; a<x; a++) {tmp[a]='*'; T; system (" CLS "); for (int b=0; b<x; b++) {cout<<tmp[b]<<}}";}} xx=2; return 0;}
#include<reg51.h> void sleep(int ms) int i; for (;ms>0;ms--) { for(i=0;i<124;i++) {;} } void main() { int t,i; for(t=1;t>0;t++) { for(i=1;i<9;i++) { p1=0xfe; sleep(200); } for(i=8;i>0;i--) { p1=0x01; sleep(200); } } }
I use the C language, please checkI have the equipment on hand and have been verified before I send it up. Using single-chip microcomputer, C programming languageIt's up to you#include<reg52.h>Sbit light1 = P1^0;Sbit Light2 = P1^1;Sbit light3 = P1^2;Sbit light4 = P1^3;Sbit Light5 = P1^4;Sbit light6 = P1^5;Sbit Light7 = P1^6;Sbit Light8 = P1^7;Void delay02s (void) / 0.2 second delay subroutine{Unsigned, char, I, J, k;For (I = 20; I > 0; i--)For (J = 20; J > 0; j--)For (k = 248; k > 0; k--);}Void, main (){While (1) {/ / lightLight1 = 0;(delay02s); / / call delayLight2 = 0;Delay02s ();Light3 = 0;Delay02s ();Light4 = 0;Delay02s ();Light5 = 0;Delay02s ();Light6 = 0;Delay02s ();Light7 = 0;Delay02s ();Light8 = 0;Delay02s ();/ / outLight1 = 1;(delay02s); / / delayLight2 = 1;Delay02s ();Light3 = 1;Delay02s ();Light4 = 1;Delay02s ();Light5 = 1;Delay02s ();Light6 = 1;Delay02s ();Light7 = 1;Delay02s ();Light8 = 1;Delay02s ();}}