サーミスタ温度センサ
温度センサ:http://wiki.seeedstudio.com/Grove-Temperature_Sensor_V1.2/
sensor = ADC.new(19)
temp = 0
while true
param = sensor.read
param = (ADC.max / param)-1
temp = 1.0/(Math.log(param)/4275+1/298.15)-273.15
puts("temp:" + temp.to_s)
sleep(1)
end
ボリューム制御
ボリュームを使用したLEDの明るさ制御ボリューム:https://www.switch-science.com/catalog/805/
volume = ADC.new(19)
led1 = PWM.new(0)
led1.frequency( 440 )
while true
param = volume.read
# adc値 × 100% ÷ adcの最大値
param = (param * 100 / ADC.max).to_i
led1.duty(param)
end
ジョイスティック
ジョイスティック:https://www.switch-science.com/catalog/884/
x = ADC.new(19)
y = ADC.new(20)
while true
puts("x:#{x.read} / y:#{y.read}")
sleep_ms(300)
end