SPI

Lab: SPI Communication With A Digital Potentiometer

截屏2021-11-01 下午2.49.08.png

https://youtu.be/cyPJKSLm-h0

// include the SPI library:
#include "SPI.h"
const int CSPin = 10;   // chip select pin number
 
void setup() {
  // initialize SPI:
  SPI.begin();
}

void loop() {
tone(9, 440); // play a tone on pin 9
 
// fade the loudness up:
for (int loudness = 100; loudness <= 255; loudness++) {
digitalPotWrite(4, loudness);
delay(20);
}
delay(1000); // delay 1 second
 
// fade the loudness down:
for (int loudness = 255; loudness >= 100; loudness--) {
digitalPotWrite(4, loudness);
delay(20);
}
 
delay(1000); // delay 1 second
}

void digitalPotWrite(int address, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(CSPin, LOW);
  // send in the address and value via SPI: 
  SPI.transfer(address);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(CSPin, HIGH);
}

Lab: OLED Screen Display using I2C

*** Reminder to install the library

https://youtu.be/tsAyjwgfrE4

After using the **font generator ,** I can easily change the fonts that display

https://youtu.be/5FkA2PzaWKk

Graphics

**Using OLED to graph the potentiometer's graph