The code below is my code to read signal for 4 Ultrasonic Sensors.
The code below works fine reading the signal, however the robot moves in a really laggy way, such that it moves for half a second, stop, move for another half a second, stop again, and move until it finishes its cycle.
[code] low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist4
wdist4 = wdist4 / 148 ;convert for inches
serout s_out, i9600, "Distance4: ", sdec wdist4, 13, 10] ;display result in terminal
toolong:
low p5
pulsout p5, 5
input p5
pulsin p5, 0, toolong1, 40000, wdist5
wdist5 = wdist5 / 148 ;convert for inches
serout s_out, i9600, "Distance5: ", sdec wdist5]
toolong1:
low p6
pulsout p6, 5
input p6
pulsin p6, 0, toolong2, 40000, wdist6
wdist6 = wdist6 / 148 ;convert for inches
serout s_out, i9600, "Distance6: ", sdec wdist6]
toolong2:
low p7
pulsout p7, 5
input p7
pulsin p7, 0, toolong3, 40000, wdist7
wdist7 = wdist7 / 148 ;convert for inches
serout s_out, i9600, "Distance7: ", sdec wdist7, 13]
toolong3: [/code]
If I were to take no signal or only 1 signal , such that
low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist4
wdist4 = wdist4 / 148 ;convert for inches
serout s_out, i9600, "Distance4: ", sdec wdist4, 13, 10] ;display result in terminal
toolong:
then the movement will be smoother.
May I ask what can I do with the program, while taking in all 4 signals from the Ultrasonic Sensors, and also at the same time not causing the movement to be ‘laggy’ ?