Changes between Version 2 and Version 3 of SPIMaster


Ignore:
Timestamp:
Feb 22, 2009 4:50:52 PM (15 years ago)
Author:
sgk
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SPIMaster

    v2 v3  
    44
    55source:/arduino-spi
     6
     7使い方の例。[http://japan.maxim-ic.com/quick_view2.cfm/qv_pk/3149 MAX6675冷接点補償K熱電対ディジタルコンバータ]から温度を読んでみました。
     8{{{
     9#include "SPI.h"
     10
     11#define SLAVE  10
     12
     13void
     14setup()
     15{
     16  Serial.begin(9600);
     17  SPI_Master.begin(SLAVE);
     18}
     19
     20void
     21loop()
     22{
     23  delay(500);
     24  long value;
     25  SPI_Master.enable(SLAVE);
     26  value = SPI_Master.read() << 8;
     27  value |= SPI_Master.read();
     28  SPI_Master.disable();
     29 
     30  if ((value & 0x0004) != 0)
     31    Serial.println("Error");
     32  else
     33    Serial.println((float)(value >> 3) / 4);
     34}
     35}}}
     36