cachomachine
Senior Member
I would like to use multitasking with a Picaxe 20M2 and a SR04 ultrasonic distance sensor
How do i acheave a 10us pulse at 4Mhz to triger the sensor?
How do i acheave a 10us pulse at 4Mhz to triger the sensor?
setfreq m4
pwm C.4,150,10
Do you mean a 10 microsecond pulse to high on a chip set up for 4 megahertz, or do you mean a waveform out at 4 megahertz, for 10 microseconds?10us pulse at 4Mhz
Hellothis works at setfreqm8 but not with setfreqm4
;Ultrasonic distance sensor
Symbol trig=c.4
Symbol echo=c.6
symbol inch=w12
distance:
setfreq m8
PulsOut trig,1 ;start a reading
PulsIn echo, 1, w13 ;return value in w13
let inch=w13*10/148/2 ;convert in inch in w13
debug
setfreq m4
goto distance
;Ultrasonic distance sensor
Symbol trig=c.4
Symbol echo=c.6
symbol inch=w12
distance:
setfreq m8
PulsOut trig,1 ;start a reading
PulsIn echo, 1, w13 ;return value in w13
let inch=w13*10/148/2 ;convert in inch in w13
debug
setfreq m4
goto distance
I mean 1 single 10us duration high pulse to trigger a reading on the SR-04 ultrasonic distance sensor
Oops!Code:setfreq m4 pwm C.4,150,10