enzi quick refference¶ ↑
digitalWrite(D0, 1)
digiralRead(D1)
analogWrite(D8, 255)
analogRead(A0)
spi = SPI.new(SPI::MSBFIRST, SPI::MODE0, SPI::CLOCK_DIV4)
result = spi.transfer(0xff)
s = Serial.new(9600)
while s.available
print s.read
end
s.write("hello")
wire = Wire.new(0x0, Wire::DutyCycle_2)
def read_register(register_address)
@wire.beginTransmission(@target)
@wire.write(register_address)
@wire.endTransmission
@wire.requestFrom(@target,1)
return @wire.read
end
def write_register(register_address,value)
@wire.beginTransmission(@target)
@wire.write(register_address)
@wire.write(value)
@wire.endTransmission
end
Watchdog¶ ↑
w = WatchdogTimer.new