Thanks. Ive seen these same sensors work with Arduino but I'll give these a go as I'm out of ideas. Hey, for $8 its worth a test. Btw. The code you gave does turn the motor but ignores the sensors.
No, it's digital reading those pins..
But if they are not connected to anything, they float..
Can replace sensors with a simple buttons/jumper wire to test code..
Might want to check the board is working properly too..
Maybe a jumper wire between each pin and ground, should be low then..
~q
I'll try the jumper wire. Easiest to test. The board seems to be working fine with simple motor control program.
-
Waiting 1 second is going to make testing extremely difficult.
-
Please draw/show a schematic showing the sensor to Arduino circuit.
Here I setup the project up in a simulator..
Uno Optical Switch Motors
Maybe you want to change the logic..
Now, both switches must be high for motor to do its movements..
~q
Well THAT'S cool!
I'll see what happens when I get the new sensors in place. So far, sensors are still ignored.
It's pretty simple. Common 5V and Grnd. I have a 100k resistor on the 5V and a 10K on the Grnd. Signal wires going to Arduino 12 and 13 pin.
Is your wiring similar to this?
Let’s see. I’ve got a 100k on the 5v pin. 10k on the ground. Nothing on the sensor pin.
Your picture shows 3 wires connected to the slot sensors, RED, GREY and YELLOW, which sensor pins (1, 2, 3, 4), does each wire connect to? On the Arduino end, what does RED, GREY and YELLOW connect to?
Red wire goes to the 5v pin. Grey (2 & 4 on your schematic) go to ground pin. The Yellow sensor to respective digital pin.
Which pin is the 5V pin, 1, 2, 3 or 4? Which pin is YELLOW connected to, 1, 2, 3 or 4?
5v is pin 1. Signal Yellow is pin 3
New sensors are working great. At least on the serial test code. They read 1 unless blocked then they read 0.
These sensors work great with the board btw
Qubits-us, Thank you for all your help! Program is working! For some reason, the Arduino didn't like the Fairchild sensors. The opto sensors you pointed me to work perfectly and give great instant feedback via the LED. Now I just have to play around to get the code timing worked out. Using your simulation code.
Kinda. Not sure exactly what your code does. Having trouble building on it without breaking it. How many cases can I add? Can I put a long (10 minute) delay in the whole routine? A delay command doesn't seem to do the trick.
As many as you wish, each one would correspond to a movement..
Each case advances the stateMove and set intervalMove to the amount of time to wait before executing the next move..
You don't want to use the delay function as it will block the sketch and you will missing the sensor..
Use intervalMove = 5000 for a 5 second wait..
Just remember the previous case sets the delay before executing the next case..
Yes, you could have a case that sets the intervalMove= (1000 * 60) * 10;
intervalMove is in milliseconds, 1000 is a second, times 60 second is a minute, times 10 minutes..
Let me know if you get stuck..
good luck.. ~q