Go Down

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

JackOWalden1Sr

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

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

PS  please post your program using the code button </>
Code: [Select]
so it looks like this
. See How to use the Forum

And if you have more questions about this project please continue them in this Thread.
Two or three hours spent thinking and reading documentation solves most programming problems.

larryd

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

Always show us your current compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
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

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

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

//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

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

larryd

if (digitalread(A0) == HIGH {switchPin 7 == HIGH};
Should be more like:
if (digitalread(A0) == HIGH)
 {
   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

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

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

INTP


JackOWalden1Sr

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;
 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;
 }
 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

 This:
if (digitalRead(A1) = HIGH);
 {
   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

Read this:
https://www.arduino.cc/en/Reference/Assignment

And read this:
https://www.arduino.cc/en/Reference/If

For each { you need a }

What are you trying to do with the sketch ?


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

Go Up