View Single Post
Old 07-09-2013, 09:03 PM   #22
jamesm
Banned
 
Join Date: Mar 2013
Drives: 2013 FR-S
Location: Orlando, FL
Posts: 2,929
Thanks: 1,166
Thanked 2,294 Times in 1,180 Posts
Mentioned: 313 Post(s)
Tagged: 4 Thread(s)
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.
jamesm is offline   Reply With Quote