Acadia Lab 203 + Lab 231

时间:2021-12-04 22:01:31

在做完 Lab 6 之后,惊觉选做实验缺口很大,于是遍历了一遍夏任务,找到了一条最省力的路线。

做完 Lab 6 的连线不用拆,可以接下来做以下两个实验:

Lab 203 网络时钟

Acadia Lab 203 + Lab 231

Acadia Lab 203 + Lab 231

核心代码如下:

void write_data(int dat)

{
int i=,temp;
RS_H;
EN_L;
temp=dat & 0xf0;
for (i=; i < ; i++)
{
if (temp&0x80)
digitalWrite(DB[i],HIGH);
else
digitalWrite(DB[i],LOW);
temp <<= ;
delay();
}
EN_H;
delay();
EN_L;
temp=(dat & 0x0f)<<;
for (i=; i < ; i++)
{
if (temp&0x80)
digitalWrite(DB[i],HIGH);
else
digitalWrite(DB[i],LOW);
temp <<= ;
delay();
}
EN_H;
delay();
EN_L;
}

视频地址如下:

http://v.youku.com/v_show/id_XMTI2MTkxNTA5Mg==.html

Lab 231 计算器

Acadia Lab 203 + Lab 231

Acadia Lab 203 + Lab 231

核心代码如下:

void getResult(void){
char c;
op1=;
op2=;
while((c = getchar())!=' '){
op1 = op1* + c - ;
}
op=getchar();
c = getchar();
while((c = getchar())!=' '&&c!='\n'){
op2 = op2* + c - ;
}
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=;
if(result_num >=){
while(result_num!=){
result[i]= result_num %+;
result_num = result_num /;
i--;
}
}
else if (result_num==)result[i]='';
else{
result_num =- result_num;
while(result_num!=){
result[i]=result_num %+;
result_num = result_num /;
i--;
}
result[i]='-';
i--;
}
while(i>){
result[i]=' ';
i--;
}
}

视频地址如下:

http://v.youku.com/v_show/id_XMTI2MTkzMzY0NA==.html