Hello Guys
i am developing arduino robot which can count the no of lines it has passed through and give the count number.
the sensor i am using to count is basically an infrared sensor module used in line follower robot
request to get help asap
So you want us to make the code for you or advice?
If the turns are sharp, all the sensors on the edge will see the curve at the same time and I used that implementation before. You simply check If {S8 and S7 and S6 are == 1} then, increase a counter.
For curves that are not sharp its a bit harder. I say you would have compare the duty cycles on each motor and when the difference is large enough you can assume that the robot is turning. This, of course, depends how well your code executes. if your robot is poorly coded and uses on-off method for steering rather than a smooth PWM aided method then it wont work.
well the code is based on on off method but it works perfectly for me.
actually this is a line following robot but i want it to read the horizontal line
for example in a t shaped path the upper part of "T"
i.e horizontal line when reached should increases the counter.
kulkarnipurvesh:
request to get help asap
Last minute school project?
We do need more information. Are you using the Arduino Robot or creating a whole new one?
With what do you need help? Electronics? code?
"Count lines" is a very wide concept. The robot needs to run forward straight on and then count?
kulkarnipurvesh:
for example in a t shaped path the upper part of "T"
i.e horizontal line when reached should increases the counter.
And then continue to go straight or follow a line left/right?
kulkarnipurvesh:
request to get help asap
The way "help" works is, you provide details of what you tried so far (code, circuit, other info) and say what's not working the way you expect it to. Then anyone who is in a position to help, will.
Until you provide details though, it looks like you expect a turnkey solution, but alas that's not the way help works.
That said, you might find inspiration here.
yeah school project.
![]()
well i am making a whole new robot.
i have developed the basic code for line following and is working pretty well.
the problem is when there are two turn left and right just like a "T" arduino should count that line where there are two turns.
for example if the count is +2 then turn left or if count is +3 turn right .
request to have a sketch (code) for the arduino.
the details of my project are as follows:-
the line following robot is using infrared led sensor to sense the path.
there are three sensor . the center sensor is is always on the black line .
if it deviates the other two sensor sends the analog value and accordingly i change the direction of the robot.
but for instance if all the sensor senses a line then i need to increment the counter by+1 every time it reaches this situation.
when the count is +1 turn right .
when count is +2 turn left or anything .
(the infrared sensor gives an analog output)
i dont know how to increment counter based on analog data.
request to get the code for the incrementing the counter based on analog input.
kulkarnipurvesh:
i have developed the basic code for line following and is working pretty well.
the problem is when there are two turn left and right just like a "T" arduino should count that line where there are two turns.
for example if the count is +2 then turn left or if count is +3 turn right .
request to have a sketch (code) for the arduino.
So you have the code, you just need to debug it!
Post your code so we can see if we can help. Remember to do it like this:
Your code, insert with the # button above the smileys.
I don't understand why a count of 2 is left and 3 is right; maybe a drawing will help me but nevermind that: assuming you're happy with that thinking, did you look at the sketch I linked in my earlier post? It shows how to count a switch, and to my way of thinking, black on white on and off is just a switch.... so it might get you started.
lets put the problem in some different way
for example if there are three analog inputs. and if all the inputs are greater than some value then increment the counter by +1
i suppose that must be easy to understand.
kulkarnipurvesh:
lets put the problem in some different way
for example if there are three analog inputs. and if all the inputs are greater than some value then increment the counter by +1
i suppose that must be easy to understand.
Doesn't that solve your problem...?
if((analogRead(One) >= 100) && (analogRead(two) >= 100) && (analogRead(three) >= 100))
{
count++;
}
Adjust where necessary o'course (due to the lack of your code)
the reply was relay helpful and the sketch worked
thanks C-F-K ![]()
kulkarnipurvesh:
the reply was relay helpful and the sketch worked
thanks C-F-K
If you where not sarcastic: Great.
If you where sarcastic: Post your code and we'll see what we can do, right now i'm (we're) blind as where the problem really is.
well the reply was NOT sarcastic
thanks again
kulkarnipurvesh:
well the reply was NOT sarcastic
thanks again
It's hard to see if something is or isn't sarcastic without seeing someones face, that's why I was a little cautious in believing it was the right answer.
Actually, you already gave your own answer in plain text. I just converted it a little bit to code.
You're welcome!