Hello
Basically if it was an LED I want the LED to be turned off when a proximity sensor detects an object, then after 2 seconds I want the LED to come back on while the prox is still sensing the object, so that it can clear the prox and start the code over for the next object to be picked up by the prox. I have changed my code so many times, and all I can come up with is the prox senses the object and turns off led but with object in front of prox i cant get nothing else to happen.
I was just useing led as an example, it is actually a motor that is turning an arm that is going in front of prox to stop motor at 12:00 position, but once arm is in front of the prox motor stops. I need something to turn on motor after a 2 second delay to clear prox and restart again. I want motor to stop for 2 seconds at 12:00 position then turn motor on till it reaches 12:00 again. I have learned a lot in this Venture but I am stuck and I need to get this project going. I am sure it's quite easy but I am new to this.
I have been working on a project, while trying to figure out how to control it, that is how i found out about Arduino, needless to say the Arduino world is new to me. The project consists of controlling a wheel chair motor via a 100 amp solid state relay with a proximity sensor. what i am trying to accomplish is the shaft of the motor will be at the center of an arm so that the prox sensor will detect when the motor has rotated to the 12:00 position. Once the prox senses the arm I want the motor to stop for 1.5 seconds and then rotate again until prox senses the arm again which will be 1/2 revolution being that it will see both ends of the arm in 1 rev pausing for 1.5 seconds each time before rotating again. The code i wrote allows me to stop the motor when the prox senses the arm but i have been trying for a week to figure out how to get it to only stop for 1.5 seconds then rotate again. Pin 12 is going to control side of the solid state relay not the actual motor. Code is below.
int sensorVal;
void setup(){
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(12, OUTPUT);
}
void loop(){
sensorVal = digitalRead(2);
// The Logic is inverted a low on pin 2 means a sinking switch is activated
// and a high on pin 2 means the switch is unactivated and pulled up by the internal resistor
// this is not a problem since the controller can interpret the data any way we tell it to
if (sensorVal == HIGH){
digitalWrite(12, HIGH);
}
if (sensorVal == LOW ){
digitalWrite (12, LOW );
}
}
Can this even be done with just the Arduino alone or do i need a motor or relay shield. I have tried putting in delays but it does not react the way i need it to.
Thanks in advance