Joe Danlloh
/
digitalPot
ddd
Fork of EthernetTester by
main.cpp
- Committer:
- idijoeteque
- Date:
- 2017-08-03
- Revision:
- 1:818e764b86f2
- Parent:
- 0:83f7908c81b1
File content as of revision 1:818e764b86f2:
#include "mbed.h" void setup() { //setup SPI, 8 bit data, high steady state clock, //second edge capture, 1MHz clock rate spi.format(8,3); spi.frequency(1000000); } void loop() { for(int level=0; level<255; level++) { digitalPotWrite(level); wait(0.1); } //wait a second at the top wait(1); for(int level = 0; level < 255; level++) { digitalPotWrite(255-level); wait(0.1); } void digitalPotWrite(int addresss, int value) { //take the SS pin low to select the chip cs = 0; //send in the address and value via SPI spi.write(address); spi.write(value); //take the SS pin high to deselect the chip cs = 1; }