IR Line Tracking Sensor (Single Bit)

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Wed Jul 27, 2016 1:03 pm

Hi there cytron...

I have just bought the particular sensor as mentioned in the subject's title

I did asked in cytron's fb, whether this sensor could be used with raspiB as well, and they say yes.

So, Ive received the sensor now (thank you Cytron, that was fast !)...but upon looking in the attachment section, the sample code provided is for Arduino...

Can I get an example for Raspberry ? thank you.

p/s: am planning to built a robot with 3 of this sensor attached. the one in the middle gonna read black the whole time, while both left and right gonna read white...
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Re: IR Line Tracking Sensor (Single Bit)

Postby Idris » Thu Jul 28, 2016 10:04 am

Hi kopytiam,

This sensor operates like a normal digital input. Maybe you can start with how to code the Raspberry Pi. You can refer to Cytron Tutorial Raspberry Pi: LED Blinking using Python. Then try to replace the push button with sensor.

Hope this help. Thanks.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Thu Jul 28, 2016 11:17 am

Idris WROTE:Hi kopytiam,

This sensor operates like a normal digital input. Maybe you can start with how to code the Raspberry Pi. You can refer to Cytron Tutorial Raspberry Pi: LED Blinking using Python. Then try to replace the push button with sensor.

Hope this help. Thanks.


hi there @Idris thank you for your response...as of the timing of this reply, im still scouring through google looking for the codes...apparently a lot of them were more arduino-related...

As for your link recommendation, I have look it through as per adviced (replace push button with sensor)...i couldnt get it what you meant by replacing the push button with sensor, because i see the GPIO for the push button were on pin 24...

i tried to build 3 cars as this attached shows...all using raspberry...the one in red, im using straight forward keyboard control to move it around
Image

as for this one...im using the hc-sr04 to have it move autonomously while detecting by itself which direction it wants to go...
Image

the previous 2 all done already...so now im working on this third one i want the car to follow the line by attaching 3 of the cytron's irline sensor that i have bought...i just need the code on how to get readings from the line sensor like this one i get for the hc-sr04...

thank you in advance @idris for your assistance...

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
TRIG = 23
ECHO = 24
print "Distance Measurement in Progress"
GPIO.setup(TRIG, GPIO.OUT)
GPIO.setup(ECHO, GPIO.IN)
GPIO.output(TRIG, False)
print "Waiting for sensor to settle..."
time.sleep(2)

GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)

while GPIO.input(ECHO) == 0:
pulse_start = time.time()
while GPIO.input(ECHO) == 1:
pulse_end = time.time()

pulse_duration = pulse_end - pulse_start
distance = pulse_duration * 17150
distance = round(distance, 2)
print "Distance : ", distance, "cm"
GPIO.cleanup()
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Re: IR Line Tracking Sensor (Single Bit)

Postby Idris » Thu Jul 28, 2016 3:13 pm

Hi kopytiam,

Good work!

Anyway do you have experience building line following robot using Arduino? If not, you still can study from Arduino example and understand the concept, because once you know the concept, you can apply to all types of controller. Since you already know how to write a coding in Raspberry Pi, plus you already develop some application on that, and for me what you share is more than beginner level (seriously), so I believe you can do it for line following robot with this sensor.

If you still insist the ready made example code, our intern is in his way to complete the tutorial, but we cannot promise when it will publish. However, I still do encourage you to try yourself first and do lot of experiment. :)
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Thu Jul 28, 2016 5:12 pm

Idris WROTE:Hi kopytiam,

Good work!

Anyway do you have experience building line following robot using Arduino? If not, you still can study from Arduino example and understand the concept, because once you know the concept, you can apply to all types of controller. Since you already know how to write a coding in Raspberry Pi, plus you already develop some application on that, and for me what you share is not a beginner level (seriously), so I believe you can do it for line following robot with this sensor.

If you still insist the ready made example code, our intern is in his way to complete the tutorial, but we cannot promise when it will publish. However, I still do encourage you to try yourself first and do lot of experiment. :)


hi @Idris...

thanks for the respond...

thats the problem im facing i guess...hehehe...not being an astute programmer is one thing, having no exposure-at-all with arduino, is another...with raspberry, I have at least attend a one day class...this is not a case of out of the blue i simply choose raspi over arduino...huhuhuhu

guess i have to wait then...really hope you guys able to make it as soon as possible

p/s: in the mean time, ive found something HERE...Ive already give it a try, but to no avail...thought the code would be that simple...kikikiki
Spoiler: show
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
GPIO.setup(26,GPIO.IN)

try:
while True:

if GPIO.input(26)==1:

print(‘The sensor sees a black/dark/non-reflective surface’)

else:

print(‘The sensor sees a white/light/reflective surface’)

time.sleep(1)

except KeyboardInterrupt:

GPIO.cleanup()

sys.exit()
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Re: IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Fri Jul 29, 2016 9:03 am

[offtopic]
Ive been stalking the tutorial section since you mention it before you guys were on to it @Idris...kikikiki...

great job cytron with the latest tutorial with the MDDS10...that'll certainly beneficial for newbies like me to have supporting content with a Malaysian-scent...kudos !
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Re: IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Fri Jul 29, 2016 12:26 pm

[update]

I have found the needed code...apparently i wasnt searching with the correct keyword...*sigh

Image
Image

with all three sensor
Image

the code i found is from
HERE

thank you @idris and cytron team for your assistance... will update once this project is done...*wink

Spoiler: show
#!/usr/bin/env python

from time import sleep
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
INPUT_PIN = 4
GPIO.setup(INPUT_PIN, GPIO.IN)

while True:
if (GPIO.input(INPUT_PIN) == True):
print('3.3')
else:
print('0')
sleep(1);
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Re: IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Thu Aug 04, 2016 8:07 pm

Finally...my own personal line following bot... :D

[youtube]https://youtu.be/BjMHq19svVo[/youtube]

Edit...ooppss...youtube tag not working...Click HERE
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Re: IR Line Tracking Sensor (Single Bit)

Postby Idris » Fri Aug 05, 2016 11:56 am

Wow terbaik! Good job! Mind to share the tutorial?
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: IR Line Tracking Sensor (Single Bit)

Postby kopytiam » Mon Aug 08, 2016 12:21 pm

Idris WROTE:Wow terbaik! Good job! Mind to share the tutorial?


Hi there @Idris...thanks for the compliments...

i didnt actually do any documentation on all of my 3 projects...it is more like a hit-and-go thingy...

however, this guy's website HERE and HERE (github repo), has been crucial for me to grasp on the concept though, and I love how he's doing it so neat with the codes and all...being a newbie, i would've love if i were able to emulate his style and give back to the community...till then, this is as far as i go with the project...
kopytiam
Freshie
 
Posts: 7
Joined: Wed Jul 27, 2016 12:55 pm

Next

Return to Sensor

Who is online

Users browsing this forum: No registered users and 5 guests

cron