Use tiny.SPI library with attiny85

hello,
I'm trying drive the digital pot MCP41010 with the attiny85 but it doesn't work
the schematic and the code are the following:
MCP41410 driver

#include <tinySPI.h>
const int CS= 1;
int value=50;
void setup() {
pinMode (CS, OUTPUT);
SPI.begin();
}

void loop() {
digitalWrite(CS, LOW);
SPI.transfer(0b00010001);
SPI.transfer(value);
digitalWrite(CS,HIGH);
}

What's wrong?

You forgot PA0 to GND

Thank for your answer but even if I connect PA0 to GND doesn't work.
Code is correct?

#include <tinySPI.h>
byte address = 0x11;
int CS= 1;
int i=0;

void setup()
{
  pinMode (CS, OUTPUT);
  SPI.begin();
  // adjust high and low resistance of potentiometer
  // adjust Highest Resistance .
   digitalPotWrite(0x00);
   delay(1000);

      // adjust  wiper in the  Mid point  .
   digitalPotWrite(0x80);
   delay(1000);

   // adjust Lowest Resistance .
   digitalPotWrite(0xFF);
   delay(1000);
}

void loop()
{
    for (i = 0; i <= 255; i++)
    {
      digitalPotWrite(i);
      delay(10);
    }
    delay(500);
    for (i = 255; i >= 0; i--)
    {
      digitalPotWrite(i);
      delay(10);
    }
}

int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}

This is the test code i found, so it looks like your code is wrong!

Thank you for your answer.
The meaning of this code is about mine even if it drives the MCP41010 first to low then to mid then to high and finally it moves the pot from lowest to highest and opposite step by step.
It uses the library command and the address as same as me.
I just tried this code too and it also do nothing. So I guess the problem is not the code.
The MCP41010 resistance is always at the midpoint of 5000Ohm when I test this code or my code. I tried multiple Attiny85 and multiple MCP41010, so the problem is not the chip too.
I'm testing on the breadboard.
Do you think that is possible, and easy transmit 8Mhz data on the breadboard from Attiny85 and MCP41010? I mean could be a breadboard problem? Any suggest to exclude this hassle?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.