wiki:SPIMaster

SPIマスター

Arduino用のSPIクラス(マスター側)を書きました。

source:/arduino-spi

使い方の例。MAX6675冷接点補償K熱電対ディジタルコンバータから温度を読んでみました。

#include "SPI.h"

#define SLAVE  10

void
setup()
{
  Serial.begin(9600);
  SPI_Master.begin(SLAVE);
}

void
loop()
{
  int value;

  delay(500);
  SPI_Master.enable(SLAVE);
  value = SPI_Master.read() << 8;
  value |= SPI_Master.read();
  SPI_Master.disable();
  
  if ((value & 0x0004) != 0)
    Serial.println("Error");
  else
    Serial.println((value >> 3) * 0.25);
}
Last modified 15 years ago Last modified on Feb 23, 2009 1:07:49 AM
Note: See TracWiki for help on using the wiki.