|
heres literally a 20-second effort at what we'd want, in Ruby just for kicks.
# half-baked example code
board = Dino::Board.new(Dino::TxRx.new)
sensor = Dino::Components::Sensor.new(pin: 'A0', board: board)
motor = Dino::SomeSubclassOfMotor.new(some_options)
TARGET_BOOST = 10.0
GAIN = 1.0
sensor.when_data_received do |data|
current_map = sensor.from_adc(data)
return if current_map == TARGET_BOOST
current_map >= TARGET_BOOST ? motor.throttle_down(GAIN) : motor.throttle_up(GAIN)
end
again just a quick thrown together example to illustrate the idea in a language people who don't code can read and understand. obviously this would probably be c, and a lot more complex.
sorry this stupid ass ancient relic-from-the-90's forum software doesn't understand markdown and won't let me format anything properly.
|