Created
January 7, 2014 07:26
-
-
Save keroxp/8295805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'arduino_firmata' | |
arduino = ArduinoFirmata.connect ENV["ARDUINO"] | |
puts "Arduino connect!! (firmata version v#{arduino.version})" | |
i = 0 | |
loop do | |
# 正弦波で温度差を分ける | |
sin = Math.sin(i*Math::PI/180.0) | |
p sin | |
hot = sin >=0 ? false : true | |
arduino.digital_write 5, hot | |
arduino.digital_write 4, !hot | |
arduino.analog_write 3, (255 * sin).abs.floor.to_i | |
sleep 0.1 | |
i += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment