Skip to content

kurod1492/kani-robo-r2p2

Repository files navigation

kani-robo-r2p2

sample

temperature

require 'adc'

def cal_temp(val)
  27 - (val * 3.3 / (1<<12) - 0.706) / 0.001721
end

adc = ADC.new(:temperature)

while true
  puts cal_temp(adc.read)
  sleep 1
end

photo reflector

  • 白のときの値 0.22 前後
  • 黒のときの値 3.3 前後
require 'adc'

adc = ADC.new(26)

while true
  puts adc.read
  sleep 1
end

LED

require "gpio"

class LED
  def intialize(pin)
    @gpio = GPIO.new(pin, GPIO::OUT)
  end

  def blink
    @gpio.write 1
    sleep 1
    @gpio.write 0
    sleep 1
  end
end

led = LED.new(25)
led.blink

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages