Hello,
Newbie here. This is my first Arduino Program. I've done this sort of thing on a PLC but not on an Arduino.
What did I get wrong?
Odd thing to me is that it seems to have gotten past the first 'if' statement. seems to hang up on the 'stop_motor' line.
Thanks in advance.
Bob
ps what is a 'code tag'?
******************* my code
// Turntable indexing control program for Arduino UNO May 2015 RHL
// set variables.... and associate with designated Arduino 'interface strip' pin NUMBERS
int stack_full = 11;
int start_motor = 8;
int slow_down = 7;
int detent = 6;
int stop_motor = 5;
boolean slow_trigger = LOW;
//the next section is about......establishing one time setup parameters ie (in this case) pin config
void setup ()
{
pinMode (stack_full, INPUT);
pinMode (detent, INPUT);
pinMode (start_motor,OUTPUT);
pinMode (slow_down, OUTPUT); //wired to pins RB1 and RB2 on Minarik board
pinMode (stop_motor, OUTPUT);
}
void loop()
{
if
(digitalRead(stack_full) == HIGH);
(digitalWrite(start_motor), HIGH;
if
(digitalRead(stack_full) == HIGH);
(digitalWrite(stop_motor), LOW);
//set timer 1 in MS ----1000 = 1sec
delay(3000)
/*
if
(digitalRead(stack_full) == HIGH)
(digitalWrite(slow_trigger),HIGH)
delay(1000) // set timer 2 (accel time)
if
(digitalRead(slow_trigger) == LOW)
(digitalWrite(slow_down, HIGH)// jumpers RB1 and RB2 via a relay from pin
if
(digitalRead(detent) == HIGH)
(digitalWrite(stop_motor,HIGH)
}
For code tags, rtfm (the sticky at the top of each forum here). How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum
Your issue is in your if statements. The structure should be:
if (conditional statement here)
{
// put code here to execute if the if statement is true
}
Note the curly brackets around the code to execute, while you used parentheses. Also, there is no semi-colon after the conditional statement, just after any commands inside the curly brackets.
An example from your code:
if (digitalRead(slow_trigger) == LOW)
{
digitalWrite(slow_down, HIGH); // jumpers RB1 and RB2 via a relay from pin
}
I added the curly brackets, and you were missing a semi-colon after the instruction.
You also have a rogue "/" in the middle of your loop. That begins a multi-line comment, and you don't have a closing "/" to end the comment, so your main loop is not closed. You probably want to nix that line?
If you're not feeling like fixing it, here's this (fixed)
// Turntable indexing control program for Arduino UNO May 2015 RHL
// set variables.... and associate with designated Arduino 'interface strip' pin NUMBERS
int stack_full = 11;
int start_motor = 8;
int slow_down = 7;
int detent = 6;
int stop_motor = 5;
boolean slow_trigger = LOW;
//the next section is about......establishing one time setup parameters ie (in this case) pin config
void setup ()
{
pinMode (stack_full, INPUT);
pinMode (detent, INPUT);
pinMode (start_motor,OUTPUT);
pinMode (slow_down, OUTPUT); //wired to pins RB1 and RB2 on Minarik board
pinMode (stop_motor, OUTPUT);
}
void loop()
{
if (digitalRead(stack_full) == HIGH){
digitalWrite(start_motor, HIGH);
digitalWrite(stop_motor, LOW);
}
//set timer 1 in MS ----1000 = 1sec
delay(3000);
if (digitalRead(stack_full) == HIGH){
digitalWrite(slow_trigger,HIGH);
}
delay(1000) // set timer 2 (accel time)
if (digitalRead(slow_trigger) == LOW){
digitalWrite(slow_down, HIGH);// jumpers RB1 and RB2 via a relay from pin
}
if (digitalRead(detent) == HIGH){
digitalWrite(stop_motor,HIGH);
}
}