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
as for this one...im using the hc-sr04 to have it move autonomously while detecting by itself which direction it wants to go...
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()