Skip to content

Commit

Permalink
Add Potentiometer example
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Sep 27, 2024
1 parent e57164c commit 10bb91d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/analog_io/potentiometer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Example for a potentiometer.
#
require 'bundler/setup'
require 'denko'

board = Denko::Board.new(Denko::Connection::Serial.new)
pot = Denko::AnalogIO::Potentiometer.new(pin: :A0, board: board)

pot.on_data do |reading|
puts "Potentiometer reading: #{reading}" if reading != pot.state
end

sleep

0 comments on commit 10bb91d

Please sign in to comment.