- C24zhuchengyu's blog
Arduino Beta
- @ 2024-7-17 19:51:49
制作不易,不喜勿喷
#include<bits/stdc++.h>
#define A0 10
#define A1 11
#define A2 12
#define a3 13
#define A4 14
#define A5 15
#define A6 16
#define A7 17
#define A8 18
#define A9 19
using namespace std;
const string HIGH="high";
const string LOW="low";
const string OUTPUT="out";
const string INPUT="in";
double v[14][2]={{5,-1},{5,-1}};
double w[8][2]={};
void pinMode(int pin,string mode){
system("mode con cols=100 lines=50");
if(pin==0||pin==1){
return;
}
else{
if(mode=="out"||mode=="in")v[pin][1]=mode=="out"?0:1;
else{
cout<<"ERROR:CODE'"<<mode<<"'SHOULD NOT BE HERE.\n";
for(int i=0;i<100;i++){
cout<<"-";
}
system("pause");
}
}
}
void digitalWrite(int pin,string mode){
system("mode con cols=100 lines=50");
if(pin>13){
cout<<"ERROR:CODE'A"<<pin%10<<"'SHOULD NOT BE HERE.\n";
for(int i=0;i<100;i++){
cout<<"-";
}
system("pause");
}
system("mode con cols=100 lines=50");
if(pin==0||pin==1){
return;
}
else if(mode=="high"||mode=="low"){
v[pin][0]=mode=="high"?5:0;
}
else{
system("mode con cols=100 lines=50");
cout<<"ERROR:CODE'"<<(mode=="out"?"OUTPUT":mode=="in"?"INPUT":mode)<<"'SHOULD NOT BE HERE.\n";
for(int i=0;i<100;i++){
cout<<"-";
}
system("pause");
}
}
void analogWrite(int pin,int mode){
system("mode con cols=100 lines=50");\
w[pin%10][0]=mode*0.0048828125;
if(pin%10>7){
system("mode con cols=100 lines=50");
cout<<"ERROR:CODE'"<<pin<<"'SHOULD NOT BE HERE.\n";
for(int i=0;i<100;i++){
cout<<"-";
}
system("pause");
}
}
int analogRead(int pin){
system("mode con cols=100 lines=50");
if(pin%10>7){
system("mode con cols=100 lines=50");
cout<<"ERROR:CODE'"<<pin<<"'SHOULD NOT BE HERE.\n";
for(int i=0;i<100;i++){
cout<<"-";
}
system("pause");
}
return w[pin%10][0]/0.0048828125;
}
int digitalRead(int pin){
system("mode con cols=100 lines=50");
if(pin>13){
system("mode con cols=100 lines=50");
cout<<"ERROR:CODE'"<<pin<<"'SHOULD NOT BE HERE.\n";
for(int i=0;i<100;i++){
cout<<"-";
}
system("pause");
}
return bool(w[pin%10][0]);
}
void vWriter(){
system("mode con cols=100 lines=50");
cout<<" temple开发板";
cout<<"\n";
cout<<" "<<"------------------------"<<"\n";
cout<<" "<<"| "<<(v[13][0]>0?"■":"□")<<"LED(13) |"<<"\n";
for(int i=0;i<7;i++){
string n=v[i*2][1]==1?"I":v[i*2][1]==0?"O":"E";
string m=v[i*2+1][1]==1?"I":v[i*2+1][1]==0?"O":"E";
string a=i*2>=10?" ":" ";
cout<<" "<<fixed<<setprecision(3)<<v[i*2][0]<<"v|-Pin"<<i*2<<"=>"<<n<<a<<m<<"<=Pin"<<i*2+1<<"-|"<<v[i*2+1][0]<<"v"<<"\n";
cout<<" "<<"| |"<<"\n";
}
for(int i=0;i<4;i++){
string n=w[i*2][1]==1?"I":w[i*2][1]==0?"O":"E";
string m=w[i*2+1][1]==1?"I":w[i*2+1][1]==0?"O":"E";
string a=" ";
cout<<" "<<fixed<<setprecision(3)<<w[i*2][0]<<"v|-Ana"<<i*2<<"=>"<<n<<a<<m<<"<=Ana"<<i*2+1<<"-|"<<w[i*2+1][0]<<"v"<<"\n";
cout<<" "<<"| |"<<"\n";
}
cout<<" "<<"| |"<<"\n";
cout<<" "<<"------------------------"<<"\n";
cout<<"----------------------------------------------------------------------------------------------------"<<"\n";
cout<<" 检测已完成,以上是系统电压"<<"\n\n\n\n";
system("pause");
}
`/* return 1:Use analog pin at digitalWrite return 2:Use */ #include using namespace std; #define A0 0 #define A1 -1 #define A2 -2 #define A3 -3 #define A4 -4 #define A5 -5 #define A6 -6 #define A7 -7 #define A8 -8 #define A9 -9 #define A10 -10 #define A11 -11 #define A12 -12 #define A13 -13 #define A14 -14 #define A15 -15 #define A16 -16 #define A17 -17 #define A18 -18 #define A19 -19 #define vcc 0x7777 #define gnd 0x8888 const int HIGH= 0x11111111; const int LOW= 0x22222222; const int OUTPUT= 0x33333333; const int INPUT= 0x44444444; int bd; const int binfo[128][4]{//0:digimax 1:anamax 2:lednum 3:height {13,6,13,12} }; const int bsize[128][2][30]{ { {vcc,0,1,2,3,4,5,6,7,8,9,10}, {gnd,11,12,13,A0,A1,A2,A3,A4,A5,A6,gnd} } }; void digitalWrite(int pin,int mode){ if(pin<=0)exit(1); if(pin>binfo[bd][0])exit(2); }