+1 (229) 255-3712
glass
pen
clip
papers
heaphones

  

This is the code I have.
# pins used:-
# AD0 [GP26] – Wiper of pot1, pot supply 0v-3.3 [5k]
# AD1 [GP27] – Wiper of pot2, pot supply 0v-3.3 [5k]
# PWN out GP0, GP2, GP3, 2 LEDs and servo output
from machine import Pin, PWM, ADC
import utime

pot1 = ADC(0) # (GPIO pins) – the position pot1
pot2 = ADC(1) # (GPIO pins) – the position pot2

servo = PWM(Pin(0)) # (GPIO pins)servo
servo.freq(50)
PWin = (3, Pin.IN, Pin.PULL_UP) # PMW wave input

L1 = Pin(2, Pin.OUT) #GPIO2 set as pin for Green LED
L2 = Pin(3, Pin.OUT) #GPIO3 set as pin for Green LED

ch1 = PWM(Pin(2)) # set ch1 for L1 to PWM using GP2
ch1.freq(1000)
ch2 = PWM(Pin(3)) # set ch2 for L2 to PWM using GP3
ch2.freq(1000)

while True:
duty = pot1.read_u16() # Copy pot Raw value to duty
value = int(1350 + (pot1.read_u16() / 9.57))
# adds the ruired offset to raw value of pot.
servo.duty_u16(value) # final value needed a bit of weaking
print(value)
L1.on()
utime.sleep(0.2)
L2.off()
utime.sleep(0.2)
L2.on()
utime.sleep(0.2)
L1.off()
utime.sleep(0.2)

I also have the physical build but the only thing working is the servo rotating.

If the fwd/rev switch is on, the motor should run forward, you need to show the reading on an oscilloscope (represented by the green led). If the fwd/rev switch is off, the motor should run in the opposite direction, you need to show the reading on an oscilloscope (represented by the red led). At any time, the rudder should move to the left or right, by adjusting the servo pot