求助-谢了一个密室解谜的小程序 校验的时候出问题了
本帖最后由 变态琳纸 于 2013-8-13 17:28 编辑这个程序我是用于密室解谜时开门前的小谜题··· 这里有6个双色LED,3个轻触开关和1个电磁继电器。只有通过按动轻触开关把6个LED全部转化成绿色之后电磁继电器将会吸合9秒,接通电子锁的电路。与此同时,必须把找到的门禁卡插在合适的位置·· 不然就重新做题···为此我就写了如下的程序····
程序如下:*/
/*
ledr1Pin=1;
ledg1Pin=2;
ledr2Pin=3;
ledg2Pin=4;
ledr3Pin=5;
ledg3Pin=6;
ledr4Pin=7;
ledg4Pin=8;
ledr5Pin=9;
ledg5Pin=10;
ledr6Pin=11;
ledg6Pin=12;
x1=13;
x2=14;
x3=15;
out1=16*/
void ln()/*不是1,是LOGIC的L,表示的是真值表,我用非门来做的,可以根据喜好更改这个真值表,比如说或门,与门,,当然,混合在一起也是可以的,但是注意别冲突,不能3个真值表函数同时使用*/
{
11==00+00;
11==00+01;
11==00+10;
11==00+11;
10==01+01;
11==01+10;
10==01+11;
01==10+10;
01==10+11;
00==11+11;
}
/*与门
void la()
{
00+00=00;
00+01=01;
00+10=10;
00+11=11;
01+01=01;
01+10=11;
01+11=11;
10+10=10;
10+11=11;
11+11=11;
}
*/
/*或门
void lo()
{
00+00=00;
00+01=01;
00+10=10;
00+11=11;
01+01=01;
01+10=11;
01+11=11;
10+10=10;
10+11=11;
11+11=11;
}
*/
void a()
{
int a=00;
int b=00;
int c=00;
if(a==00)
{
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
if(a==01)
{
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
}
if(a==10)
{
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
if(a==11)
{
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
}
if(b==00)
{
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
}
if(b==01)
{
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
}
if(b==10)
{
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
}
if(b==11)
{
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
}
if(c==00)
{
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
}
if(c==01)
{
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
}if(c==10)
{
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
}
if(c==11)
{
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
}
}
void setup()
{
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,INPUT);
pinMode(14,INPUT);
pinMode(15,INPUT);
pinMode(16,OUTPUT);
//设定数字I/O口为输出状态等,S1-S3作为轻触开关的输入口,OUT1继电器的输出口
}
void loop()
{
int a1;
int a2;
int a3;
int a4;
a1=random(1,99);
a2=random(1,99);
a3=random(1,99);
a4=random(1,99);
if(a1>a2>a3>a4)
{
int s1=00;
int s2=01;
int s3=10;
}
else if(a1>a2>a4>a3)
{
int s1=00;
int s2=01;
int s3=11;
}
else if(a1>a3>a2>a4)
{
int s1=00;
int s2=10;
int s3=01;
}
else if(a1>a3>a4>a2)
{
int s1=00;
int s2=10;
int s3=11;
}
else if(a1>a4>a3>a2)
{
int s1=00;
int s2=11;
int s3=10;
}
else if(a1>a4>a2>a3)
{
int s1=00;
int s2=11;
int s3=01;
}
else if(a2>a1>a3>a4)
{
int s1=01;
int s2=00;
int s3=10;
}
else if(a2>a1>a4>a3)
{
int s1=01;
int s2=00;
int s3=11;
}
else if(a2>a3>a4>a1)
{
int s1=01;
int s2=10;
int s3=11;
}
else if(a2>a3>a1>a4)
{
int s1=01;
int s2=10;
int s3=00;
}
else if(a2>a4>a3>a1)
{
int s1=01;
int s2=11;
int s3=10;
}
else if(a2>a4>a1>a3)
{
int s1=01;
int s2=11;
int s3=00;
}
else if(a3>a1>a2>a4)
{
int s1=10;
int s2=00;
int s3=01;
}
else if(a3>a1>a4>a2)
{
int s1=10;
int s2=00;
int s3=11;
}
else if(a3>a2>a1>a4)
{
int s1=10;
int s2=01;
int s3=00;
}
else if(a3>a2>a4>a1)
{
int s1=10;
int s2=01;
int s3=11;
}
else if(a3>a4>a2>a1)
{
int s1=10;
int s2=11;
int s3=01;
}
else if(a3>a4>a1>a2)
{
int s1=10;
int s2=11;
int s3=00;
}
else if(a4>a3>a2>a1)
{
int s1=11;
int s2=10;
int s3=01;
}
else if(a4>a3>a1>a2)
{
int s1=11;
int s2=10;
int s3=00;
}
else if(a4>a2>a3>a1)
{
int s1=11;
int s2=01;
int s3=10;
}
else if(a4>a2>a1>a3)
{
int s1=11;
int s2=01;
int s3=00;
}
else if(a4>a1>a2>a3)
{
int s1=11;
int s2=00;
int s3=01;
}
else if(a4>a1>a3>a2)
{
int s1=11;
int s2=00;
int s3=10;
}
whilea(a==00&&a==01&&a==10&&b==00&&b==01&&b==10&&c==00&&c==01&&c==10)
{
if(13==HIGH){
a=s1+a;
if(13==HIGH){
b=s1+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;
}
else if(15==HIGH){
c=s3+c;
}
}
else if(14==HIGH){
b=s2=b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;
}
else if(15==HIGH){
c=s3+c;
}
}
else if(15==HIGH){
b=s3+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;
}
else if(15==HIGH){
c=s3+c;
}
}
}
else if(14==HIGH){
a=s2+a;
if(13==HIGH){
b=s1+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;}
else if(15==HIGH){
c=s3+c;}
}
else if(14==HIGH){
b=s2+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;}
else if(15==HIGH){
c=s3+c;}
}
else if(15==HIGH){
b=s3+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;}
else if(15==HIGH){
c=s3+c;}
}
}
else if(15==HIGH){
a=s3+a;
if(13==HIGH){
b=s1+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;}
else if(15==HIGH){
c=s3+c;}
}
else if(14==HIGH){
b=s2+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;}
else if(15==HIGH){
c=s3+c;}
}
else if(15==HIGH){
b=s3+b;
if(13==HIGH){
c=s1+c;
}
else if(14==HIGH){
c=s2+c;}
else if(15==HIGH){
c=s3+c;}
}
}
}
if(a=11&&b=11&&c=11)
{
digitalWrite(16,LOW);
}
else
{
digitalWrite(16,HIGH);
}
delay(10000);
}
校验报错如下:
sketch_aug13a:0: error: expected unqualified-id before '/' token
sketch_aug13a:0: error: expected constructor, destructor, or type conversion before '/' token
sketch_aug13a.cpp: In function 'void loop()':
sketch_aug13a:328: error: ISO C++ forbids comparison between pointer and integer
sketch_aug13a:328: error: ISO C++ forbids comparison between pointer and integer
sketch_aug13a:328: error: 'b' was not declared in this scope
sketch_aug13a:328: error: 'c' was not declared in this scope
sketch_aug13a:328: error: 'whilea' was not declared in this scope
sketch_aug13a:329: error: expected `;' before '{' token
sketch_aug13a:447: error: expected `}' at end of input
百思不得其解的是就连自己怎么错都不知道···· 錯誤訊息:
1. 一開始的註解寫反了,應該是 /*...*/
2. 第329行寫成whilea Be1ieve 发表于 2013-8-13 19:57 static/image/common/back.gif
錯誤訊息:
1. 一開始的註解寫反了,應該是 /*...*/
2. 第329行寫成whilea
这个我复制代码的时候忘了删了 =。=
329行那里真的不知道怎么改··· 查了好多资料都看的不明不白的·· 嗯...329是while()不是whilea()
而且這個根本不會滿足吧
然後上面那一串數字是怎麼回事...
可以講解一下你想要做什麼嗎 Be1ieve 发表于 2013-8-13 20:53 static/image/common/back.gif
嗯...329是while()不是whilea()
而且這個根本不會滿足吧
我想做一个密室解谜时开门前的小谜题··· 这里有6个双色LED(红绿),3个轻触开关和1个电磁继电器。只有通过按动不同的轻触开关把6个LED全部转化成绿色之后电磁继电器将会吸合9秒,接通电子锁的电路。与此同时,必须把找到的门禁卡插在合适的位置·· 不然就重新做题···
页:
[1]