Go Down

### Topic: then //How do you declare “then” in this scope? (Read 2460 times)previous topic - next topic

#### JackOWalden1Sr

##### Aug 13, 2017, 03:51 pm
void setup() {
const int switchPin = 8;
unsigned long previousTime = .0152;
int switchState = .0152;
int prevSwitchState = .0152;
int Time = 2;
long interval = 1;
for(int x = 2;x<8;x++){
pinMode(x, OUTPUT);
then == switchPIN
}
int then == pinMode
pinMode(switchPin, OUTPUT);
if (A0 == HIGH, then, switchPin 7 == HIGH;
if (A1 == HIGH, then, switchPin 6 == HIGH;
if (A2 == HIGH, then, switchPin 2 == HIGH;
if (A3 == HIGH, then, switchPin 3 == HIGH;
if (A4 == HIGH, then, switchPin 4 == HIGH;
if (A5 == HIGH, then, switchPin 5 == HIGH;
//How do you declare "then" in this scope?

#### Robin2

#1
##### Aug 13, 2017, 04:03 pmLast Edit: Aug 13, 2017, 04:03 pm by Robin2
This does not make sense
Code: [Select]
`int then == pinMode `
because pinMode() is a function that sets the mode of an I/O pin

You need to declare a variable before you use it. So you would need to have
Code: [Select]
`int then;`
before the line
Code: [Select]
`then == switchPIN `

But the word "then" seems a most unintuitive name for a variable and I have no idea why you want two variables (then and switchPIN having the value 8 )

Maybe you mean something like
Code: [Select]
`then = digitalRead(switchPin);`

All of the Arduino functions are explained in the Reference section

Another good way to learn is to study the many examples that come with the Arduino IDE

...R

Code: [Select]
`so it looks like this`
. See How to use the Forum

Two or three hours spent thinking and reading documentation solves most programming problems.

#### larryd

#2
##### Aug 13, 2017, 04:17 pm
unsigned long previousTime = .0152;
int switchState = .0152;
Do you know what an integer is?

Do you know what an analog pin is?

No technical PMs.
The last thing you did is where you should start looking.

#### larryd

#3
##### Aug 13, 2017, 04:17 pm
Always show us your current compete sketch.
Use CTRL T to format the sketch.
Use the </> icon in the posting menu.
[code] Paste sketch here. [/code]

No technical PMs.
The last thing you did is where you should start looking.

#### UKHeliBob

#4
##### Aug 13, 2017, 05:11 pm
Your question and code raise many questions.

Let's deal with a simple one.  Examine this code
Code: [Select]
`if (digitalRead(A0) == HIGH)  //test whether pin A0 is HIGH{  //execute the code between the curly brackets if the test above returns true.}`
Does that go any way towards any part of your questions ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

#### INTP

#5
##### Aug 13, 2017, 07:12 pm
You can't make up your own language and expect the program to understand. Take a few minutes looking at example code and see how they work.

#### JackOWalden1Sr

#6
##### Aug 13, 2017, 11:40 pm
//Proof read this?...this creates error code:exit status 1...'digitalread' was not declared in this scope.

void setup() {

unsigned long previousTime = .0152;
int switchState = .0152;
int prevSwitchState = .0152;
int Time = 2;
long interval = 1;
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
int switchPin = pinMode;
int then();
then == switchPin;
if (digitalread(A0) == HIGH {switchPin 7 == HIGH};
if (digitalread(A1) == HIGH {switchPin 6 == HIGH};
if (digitalread(A2) == HIGH {switchPin 2 == HIGH};
if (digitalread(A3) == HIGH {switchPin 3 == HIGH};
if (digitalread(A4) == HIGH {switchPin 4 == HIGH};
if (digitalread(A5) == HIGH {switchPin 5 == HIGH};
{
}
}
//How do you declare "then" in this scope?
}
void loop() {
unsigned long currentTime = millis();
int Time = 2;
long interval = 1;
}

#### larryd

#7
##### Aug 13, 2017, 11:52 pm
This should be

.
No technical PMs.
The last thing you did is where you should start looking.

#### larryd

#8
##### Aug 13, 2017, 11:54 pmLast Edit: Aug 14, 2017, 02:10 am by larryd
if (digitalread(A0) == HIGH {switchPin 7 == HIGH};
Should be more like:
{
switchPin 7 = HIGH;
}

int switchState = .0152;
Do you know what an 'integer' is?
No technical PMs.
The last thing you did is where you should start looking.

#### slipstick

#9
##### Aug 14, 2017, 12:04 am
1. You can't assign a value of .0152 to an int, int means integer. Decimals aren't integers.

2. You need to know the difference between an assignment (=) and a comparison (==). Then you might realise at least one reason why "then == switchPin;" makes no sense.

3. When you open brackets you need to close them. Unlike in all your if statements.

4. "{switchPin 7 == HIGH} and its variants are gibberish. You're apparently comparing 7 with HIGH and then doing nothing with any result.

Whatever language you're writing your code in it isn't one that any Arduino (or C++ programmer) is going to recognise.

Steve

#### larryd

#10
##### Aug 14, 2017, 01:11 am
I smell a troll.

.
No technical PMs.
The last thing you did is where you should start looking.

#### INTP

#11
##### Aug 14, 2017, 01:22 am
Spaces in variable names.

#### JackOWalden1Sr

#12
##### Aug 14, 2017, 01:36 am
void setup() {
unsigned long previousTime = 1520;
int switchState = 1520;
int prevSwitchState = 1520;
int Time = 2;
long interval = 1;
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
int switchPin = pinMode;
int then();
then == switchPin;
{
switchPin 7 == HIGH;
}
{
switchPin 6 == HIGH;
}
{
switchPin 2 == HIGH;
}
{
switchPin 3 == HIGH;
}
{
switchPin 4 == HIGH
}
{
switchPin 5 == HIGH;
}
void loop() {
unsigned long currentTime = millis();
int Time = 2;
long interval = 1;
}

//How do you declare "then" in this scope?...This is "hung up" on switchPin 5

#### larryd

#13
##### Aug 14, 2017, 01:51 am
This:
{
switchPin 6 == HIGH;
}
Should be:
if (digitalRead(A1) == HIGH);  <-----<<<<< two =
{
switchPin 6 = HIGH; <-----<<<<< one =
}

There is no function called:    then()
int then();  <-----<<<<< Tell us what you think is happening here.

then == switchPin; <-----<<<<< use one  =  but you should use names that mean something.

You really should master some of the basic examples that are installed with the IDE.

No technical PMs.
The last thing you did is where you should start looking.

#### larryd

#14
##### Aug 14, 2017, 01:52 amLast Edit: Aug 14, 2017, 02:12 am by larryd
https://www.arduino.cc/en/Reference/Assignment