Hello Guys,
I am quite new to Arduino and digital electronics in General.
Newly I have to work with a Digital Potentiometer (MSP4142) and write a small Code to test how it should work with arduino:
Here it is: It makes a Led connected to Digital 10 blink every 250 mS.
#include <SPI.h> // necessary library
int ss= 10; // using digital pin 10 for SPI slave select
int del=250; // used for various delays
void setup()
{
pinMode(ss, OUTPUT); // we use this for SS pin
SPI.begin(); // wake up the SPI bus.
SPI.setBitOrder(MSBFIRST);
// our MCP4162 requires data to be sent MSB (most significant byte) first
}
void setValue(int value)
{
digitalWrite(ss, LOW);
SPI.transfer(0); // send command byte
SPI.transfer(value); // send value (0~255)
digitalWrite(ss, HIGH);
}
void loop()
{
setValue(255);
delay(del);
setValue(0);
delay(del);
}
But (unfortunately) for my project, I want to work with an ATtiny chip. I have the ATtiny 85. I have been reading a lot on internet about how to hook up ATtiny and DigiPot (thru SPI) and I am totally Lost.
I mean, I think I have to connect :
SCK > Digi2, PIN7 Attiny
SDI > Digi0, PIN5 Attiny
And then I define CS as Digi1, PIN6 Attiny - I don't need the SDO.
It ain't working, It wont even compile in Arduino.
Can anyone tell me if it is at least possible?
Or do I have to use any other ATtiny Chip? If yes which one?
Thanks a Million in Advance for your help.
Clément