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?
This does not make sense
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
int then;
before the line
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
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 </>
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.
unsigned long previousTime = .0152;
int switchState = .0152;
Do you know what an integer is?
Do you know what an analog pin is?
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]
Your question and code raise many questions.
Let's deal with a simple one. Examine this code
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 ?
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.
//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;
}
digitalread
This should be
digitalRead
.
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?
-
You can't assign a value of .0152 to an int, int means integer. Decimals aren't integers.
-
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.
-
When you open brackets you need to close them. Unlike in all your if statements.
-
"{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
I smell a troll.
.
Spaces in variable names.
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
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.
Read this:
And read this:
https://www.arduino.cc/en/Reference/If
For each { you need a }
What are you trying to do with the sketch ?
.
Troll or very 'analogWrite(ledPin, 1); //active high LED' individual.
JackOWalden1Sr:
// How do you declare “then” in this scope?... This is "hung up" on switchPin 5
You don't.
Since you don't know how to program and have said that you don't want to learn and you can't pay someone to do the programming you are in for a heap of trouble. You seem to be typing in nearly random strings of symbols and then asking how to fix your code.
I have fixed your code to make it compile. This involved adding some missing declarations, adjusting the symbols to match the apparent intent, and commenting out several lines of complete nonsense, particularly the use of "then". Your code still does nothing but at least it compiles with only warnings, not errors.
boolean switchPin2, switchPin3, switchPin4, switchPin5, switchPin6, switchPin7;
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)
switchPin7 = HIGH;
if (digitalRead(A1) == HIGH)
switchPin6 = HIGH;
if (digitalRead(A2) == HIGH)
switchPin2 = HIGH;
if (digitalRead(A3) == HIGH)
switchPin3 = HIGH;
if (digitalRead(A4) == HIGH)
switchPin4 = HIGH;
if (digitalRead(A5) == HIGH)
switchPin5 = HIGH;
}
void loop() {
unsigned long currentTime = millis();
int Time = 2;
long interval = 1;
}
larryd:
I smell a troll.
Seem legit enough at least when it comes to previous posts on solar tracking: Jack Walden - Walden's Greenergy Solar, LLC | LinkedIn
Very generous @johnwasser
I'm not entirely sure if the OP is a troll or not, but certainly needs a lot of help understanding the very basics.
Should send him off to Arduino kindergarten ASAP
if (digitalRead(A1) = HIGH);
{
switchPin 6 == HIGH;
}
Should be:
if (digitalRead(A1) == HIGH); <-----<<<<< two =
{
switchPin 6 = HIGH; <-----<<<<< one =
}
Should be
if (digitalRead(A1) == HIGH) //no semicolon at the end of the statement