Skip to content

Commit 10bb91d

Browse files
committed
Add Potentiometer example
1 parent e57164c commit 10bb91d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

examples/analog_io/potentiometer.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Example for a potentiometer.
3+
#
4+
require 'bundler/setup'
5+
require 'denko'
6+
7+
board = Denko::Board.new(Denko::Connection::Serial.new)
8+
pot = Denko::AnalogIO::Potentiometer.new(pin: :A0, board: board)
9+
10+
pot.on_data do |reading|
11+
puts "Potentiometer reading: #{reading}" if reading != pot.state
12+
end
13+
14+
sleep

0 commit comments

Comments
 (0)