hi lads looking for a bit of advise hear. I keep getting errors hear. I was getting one saying that pins have no value. but that seams to be gone now. I cant seam to get rid of the error I have left witht he brackets. can any one help thanks
void setup()
{
int pinOUT = 7;
int pinA = 8;
int pinB = 9;
}
{
pinMode(pinOUT,OUTPUT);
pinMode(pinA,INPUT);
pinMode(PinB,INPUT};
}
void loop() {
// put your main code here, to run repeatedly:
boolean pinAstate - digitalRead(pinA);
boolean pinBstate = digitalRead(pinB);
boolean pinOUTPUTstate;
// and
pinOUTstate = PinAstate & pinBstate;
digitalWrite(pinOUT,pinOUTstate);
}
my error reads
PinB was not declared in this scope
void setup()
{
int pinOUT = 7;
int pinA = 8;
int pinB = 9;
} // end of setup
{ // dissassociated block starts here
pinMode(pinOUT, OUTPUT);
pinMode(pinA, INPUT);
pinMode(PinB, INPUT
}; // bracket followed by unnecessary semicolon
} // extra bracket
void loop() {
// put your main code here, to run repeatedly:
boolean pinAstate - digitalRead(pinA);
boolean pinBstate = digitalRead(pinB);
boolean pinOUTPUTstate;
// and
pinOUTstate = PinAstate & pinBstate;
digitalWrite(pinOUT, pinOUTstate);
}
Plus, your local variables declared in setup() will be destroyed once setup() ends, make them Global so that they can be used in loop().
thanks for the help. but I still cant get it to work. I am new to this programing so don't have much about it yet.
I changed the program around a bit and that has seam to got rid of the error I had. but now I am getting one that says pinOUT, pinA and pinB ware not declared in this scope.
int pinOUT = 7;
int pinA = 8;
int pinB = 9;
void setup()
{
pinMode(pinOUT, OUTPUT);
pinMode(pinA, INPUT);
pinMode(PinB, INPUT);
}
Just a quick tip from one new user to another, C programming is completely case sensitive, so if you name something "PinA" in one part of your program you must use that EXACT name throughout the program. I haven't yet tested it but I believe you could have PinA, pinA, and Pina as separate names in the same function as long as they had all been declared in the Setup.
Kiwi_Bloke:
Just a quick tip from one new user to another, C programming is completely case sensitive, so if you name something "PinA" in one part of your program you must use that EXACT name throughout the program. I haven't yet tested it but I believe you could have PinA, pinA, and Pina as separate names in the same function as long as they had all been declared in the Setup.
One good way I had of obfuscating BASIC programs after they had been developed and were ready for distribution, was to run the code through a program that changed the name of all variables into one word but with a mixture of upper case and lower case letters to make them different.
It was impossible to read the code but it ran just fine.
Grumpy_Mike:
One good way I had of obfuscating BASIC programs after they had been developed and were ready for distribution, was to run the code through a program that changed the name of all variables into one word but with a mixture of upper case and lower case letters to make them different.
It was impossible to read the code but it ran just fine.
"C Journal" or whatever name they changed to used to have "obfuscated code " contest.
Maybe this forum should have one once a while.
I suppose the contest entries would have to be enclosed in code quotes to qualify.
Bummer , that leaves me out.
Seriously - how about "sticky / or stickie ?" on most common C coding errors?
C / C++/ C# is case sensitive
C / C++/ C# commands terminate with semicolon ";"
Code without comments is like day without a sunshine
Code without comments may keep your job longer or very short.
Vaclav:
"C Journal" or whatever name they changed to used to have "obfuscated code " contest.
Maybe this forum should have one once a while.
I suppose the contest entries would have to be enclosed in code quotes to qualify.
Bummer , that leaves me out.
Seriously - how about "sticky / or stickie ?" on most common C coding errors?
C / C++/ C# is case sensitive
C / C++/ C# commands terminate with semicolon ";"
Code without comments is like day without a sunshine
Code without comments may keep your job longer or very short.
Code with incorrect comments is misleading
Code with comments that echo the code is utterly pointless