I am trying to program a Hydraulic pusher that has to move all the way to the right when the ventile is open and the motor is on.The motor is put on with the button called button. when the valve is pushed down the valve is open. when the valve is pushed down it lands on an electromagnet that keeps the valve open I press the button and the and the motor goes on and The Hydraulic pusher moves
I make the electromagnet stop when working when the switch is pressed or when the emergency stop is pressed. making the Hydraulic pusher stand still.
then if I pressed another button called button. I want the Hydraulic pusher to move back a little and when I press the button called buttons again I want it to move the same amount backward. I am getting all kinds of errors and I am new to Arduino so I do not have the knowledge to do it Myself.
this is my code
int motorRelaiPin = 2;
int switchPin = 4 ;
int button = 7;
int electromagnet = 8;
int buttons = 12;
int noodstop = 13;
int num;
void setup ()
{
pinMode(MoterRelaiPin, OUTPUT);
pinMode(switchPin, INPUT);
pinMode(button, INPUT);
pinMode(electromagnet OUTPUT);
pinMode(buttons, INPUT);
pinMode(noodstop = INPUT);
}
void loop ()
{
if (digitalRead(switchPin) == HIGH || noodstop = HIGH);
{
digitalWrite(electromagnet == LOW);
}
else
{
digitalWrite(electromagnet, HIGH);
}
switch(num) {
case 0;
digitalRead(button, HIGH);
delay(50);
digitalWrite(MoterRelaiPin, HIGH);
break;
case 1;
digitalRead(buttons , HIGH);
delay(50);
digitalWrite(MoterRelaiPin, LOW);
delay(500);
digitalWrite(moterRelaiPin, HIGH);
break;
case 2;
digitalRead(buttons, HIGH);
(50);
digitalWrite(MoterRelaiPin, HIGH);
delay(500);
digitalWrite(MoterRelaiPin, LOW);
break;
}
And please post your code between [code] [/code] tags so
your code looks like this
and is easy to copy to a text editor
I strongly suspect that you will find it much easier to write ad=nd debug your code if you give meaningful names to things rather than "button called button". For example what about startButton and backButton
And if you want a responsive program all those delay()s will have to go because the Arduino can do nothing else during a delay(). Have a look at how millis() is used to manage timing without blocking in several things at a time
You should post the FULL error message, preferably using code tags as described below.
You seem to be missing one or more '}'; there might be more wrong.
Please edit your post and use code tags
type ** **[code]** **
before the code
type ** **[/code]** **
after the code
And in future please use the auto-format tool in the IDE to properly indent your code before posting; it might have made the problem clear to you immediately.
Please post the complete text of the error message(s). The newer IDE makes it easy to copy the error, use the copy error message button. Then paste into code tags.
Arduinos:1: error: expected unqualified-id before '[' token
^
C:\Users\Omar\Downloads\Arduinos\Arduinos.ino: In function 'void setup()':
Arduinos:12: error: 'MoterRelaiPin' was not declared in this scope
pinMode(MoterRelaiPin, OUTPUT);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ')' before numeric constant
#define OUTPUT 0x1
^
C:\Users\Omar\Downloads\Arduinos\Arduinos.ino:15:23: note: in expansion of macro 'OUTPUT'
pinMode(electromagnet OUTPUT);
^
Arduinos:15: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'
pinMode(electromagnet OUTPUT);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here
void pinMode(uint8_t, uint8_t);
^
Arduinos:17: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'
pinMode(noodstop = INPUT);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: declared here
void pinMode(uint8_t, uint8_t);
^
C:\Users\Omar\Downloads\Arduinos\Arduinos.ino: In function 'void loop()':
Arduinos:21: error: lvalue required as left operand of assignment
if (digitalRead(switchPin) == HIGH || noodstop = HIGH);
^
Arduinos:23: error: too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'
digitalWrite(electromagnet == LOW);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here
void digitalWrite(uint8_t, uint8_t);
^
Arduinos:25: error: 'else' without a previous 'if'
else
^
Arduinos:31: error: expected ':' before ';' token
case 0;
^
Arduinos:32: error: too many arguments to function 'int digitalRead(uint8_t)'
digitalRead(button, HIGH);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:135:5: note: declared here
int digitalRead(uint8_t);
^
Arduinos:34: error: 'MoterRelaiPin' was not declared in this scope
digitalWrite(MoterRelaiPin, HIGH);
^
Arduinos:37: error: expected ':' before ';' token
case 1;
^
Arduinos:38: error: too many arguments to function 'int digitalRead(uint8_t)'
digitalRead(buttons , HIGH);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:135:5: note: declared here
int digitalRead(uint8_t);
^
Arduinos:42: error: 'moterRelaiPin' was not declared in this scope
digitalWrite(moterRelaiPin, HIGH);
^
Arduinos:45: error: expected ':' before ';' token
case 2;
^
Arduinos:46: error: too many arguments to function 'int digitalRead(uint8_t)'
digitalRead(buttons, HIGH);
^
In file included from sketch\Arduinos.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:135:5: note: declared here
int digitalRead(uint8_t);
^
Arduinos:52: error: expected identifier before '/' token
^
C:\Users\Omar\Downloads\Arduinos\Arduinos.ino: In lambda function:
Arduinos:52: error: expected '{' at end of input
[/code]
^
C:\Users\Omar\Downloads\Arduinos\Arduinos.ino: In function 'void loop()':
Arduinos:52: error: expected ';' at end of input
Arduinos:52: error: expected '}' at end of input
Arduinos:52: error: expected '}' at end of input
exit status 1
expected unqualified-id before '[' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.