在做完 Lab 6 之后,惊觉选做实验缺口很大,于是遍历了一遍夏任务,找到了一条最省力的路线。
做完 Lab 6 的连线不用拆,可以接下来做以下两个实验:
Lab 203 网络时钟
核心代码如下:
void write_data(int dat) { int i=0,temp; RS_H; EN_L; temp=dat & 0xf0; for (i=0; i < 4; i++) { if (temp&0x80) digitalWrite(DB[i],HIGH); else digitalWrite(DB[i],LOW); temp <<= 1; delay(1); } EN_H; delay(10); EN_L; temp=(dat & 0x0f)<<4; for (i=0; i < 4; i++) { if (temp&0x80) digitalWrite(DB[i],HIGH); else digitalWrite(DB[i],LOW); temp <<= 1; delay(1); } EN_H; delay(10); EN_L; }
视频地址如下:
http://v.youku.com/v_show/id_XMTI2MTkxNTA5Mg==.html
Lab 231 计算器
核心代码如下:
void getResult(void){ char c; op1=0; op2=0; while((c = getchar())!=‘ ‘){ op1 = op1*10 + c - 48; } op=getchar(); c = getchar(); while((c = getchar())!=‘ ‘&&c!=‘\n‘){ op2 = op2*10 + c - 48; } switch(op){ case ‘+‘: result_num=op1+ op2; break; case ‘-‘: result_num = op1- op2; break; case ‘*‘: result_num = op1* op2; break; case ‘/‘: result_num = op1/ op2; break; } int i=31; if(result_num >=0){ while(result_num!=0){ result[i]= result_num %10+48; result_num = result_num /10; i--; } } else if (result_num==0)result[i]=‘0‘; else{ result_num =- result_num; while(result_num!=0){ result[i]=result_num %10+48; result_num = result_num /10; i--; } result[i]=‘-‘; i--; } while(i>0){ result[i]=‘ ‘; i--; } }
视频地址如下:
http://v.youku.com/v_show/id_XMTI2MTkzMzY0NA==.html
时间: 2024-10-18 06:47:16