Created
August 18, 2013 18:11
-
-
Save ypelletier/6263075 to your computer and use it in GitHub Desktop.
Sketch pour contrôler un potentiomètre numérique MCP41100 au moyen d'un Arduino Uno.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************** | |
Sketch pour contrôler un potentiomètre numérique | |
MCP41100 au moyen d'un Arduino Uno. | |
http://electroniqueamateur.blogspot.ca/2013/04/faire-varier-une-resistance-au-moyen-de.html | |
**********************************************************/ | |
#include <SPI.h> | |
const int slaveSelectPin = 10; | |
void setup() | |
{ | |
pinMode (slaveSelectPin, OUTPUT); | |
SPI.begin(); | |
} | |
void loop() | |
{ | |
digitalPotWrite(0); // valeur minimale | |
delay(10000); | |
digitalPotWrite(255); // valeur maximale | |
delay(10000); | |
digitalPotWrite(128); // valeur médiane | |
delay(10000); | |
} | |
int digitalPotWrite(int value) | |
{ | |
digitalWrite(slaveSelectPin, LOW); | |
SPI.transfer(0x11); | |
SPI.transfer(value); | |
digitalWrite(slaveSelectPin, HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment