I’ve 5V and 3.3 volts from a LiDAR if there is any obstacle. I’ve used these two cases to change the mode of the rover to stop.
I’m not sure where I’m doing wrong.
My Ardu version: 4.5.7
Case 1 using AUX / GPIO pin
I firstly change SERVOx_FUNCTION parameter is to “-1”.
gpio:pinMode(53,0) -- set AUX 2 to input, gpio:pinMode(51,1) would be output
local function aux1_is_high()
gcs:send_text(3, "getting high")
return gpio:read(53) == 1
end
function update()
local mode = vehicle:get_mode()
-- Check AUX1 GPIO voltage
local aux1 = aux1_is_high()
-- If AUX1 has voltage (3.3V detected), switch to MANUAL mode
if aux1 and (mode == 10 or mode == 15) then
gcs:send_text(3, "Obstacle voltage detected! Switching to MANUAL.")
vehicle:set_mode(0) -- MANUAL mode
end
return update, 1000 -- Check every 1 second
end
Case II - ADC
| Pin | Signal | Volt |
|---|---|---|
| 1 (red) | VCC | +5V |
| 2 (blk) | ADC IN | |
| 3 (blk) | GND | GND |
What could be best case. Please check the wiring in the attached picture.
Is there anything, I’m missing, Please help
