avatar

JamesCarruthers

Member Since: July 7, 2012

Country: United Kingdom

  • Product COM-09766 | about 2 years ago

    To give people a head start with the SPI — this displays “1234”

    Most important part is to turn down the SPI clock.

    #include SPI.h //put brackets around here as usual!
    
    const int slaveSelectPin = 10;
    
    void setup() {
        pinMode (slaveSelectPin, OUTPUT);
        SPI.begin();
        SPI.setBitOrder(MSBFIRST);
        SPI.setDataMode(SPI_MODE0);
        SPI.setClockDivider(SPI_CLOCK_DIV128);
    }
    
    void loop() {
        digitalWrite(slaveSelectPin,LOW);
        SPI.transfer(1);
        SPI.transfer(2);
        SPI.transfer(3);
        SPI.transfer(4);
        digitalWrite(slaveSelectPin,HIGH);
    }
    

No public wish lists :(