I am connecting a mcp4132 in attiny 85, but it does not have ss. how can I solve it?

I am connecting a mcp4132 in attiny 85, but it does not have ss. how can I solve it?

As the device data sheet clearly explains, use /CS instead.

Sorry, I did not express myself well, attiny85 does not have ss or sc.
I'm new to this anyway and I still don't quite understand everything. The code I am using is this.
Is there a way to communicate with the mcp without the attiny85 having ss or sc?

#include <SPI.h>
int ss =  2; // slave select pins

void setup() {

// set SS pin directions
// Others are handled automatically

pinMode(ss, OUTPUT);

//Initialize SPI
SPI.begin();

Serial.begin(9600);

}
// function to set LED to specific level
// reg is the register, register is the index - this is only one pot,
// so the reg is == 00000000
// level is the leve

void setLed(int reg, int level) {

digitalWrite(ss, LOW); // set SS to low for communicating to that chip
SPI.transfer(reg); // send register / index
SPI.transfer(level);
digitalWrite(ss, HIGH); // Finish writing to that chip
}

void loop() {

for(int i = 0; i<255; i++) {

setLed(0, i);
delay(20);

Serial.println(i);
}

delay(500);

for(int i = 255; i<=0; i--) {

setLed(0, i);
delay(20);

Serial.println(i);
}



delay(500);
}

The code you posted is most likely intended for a standard Arduino, and probably won't work with an ATtiny85, which does not have a separate SPI interface.

The ATtiny85 can be made to work, but you will have a much easier time getting started if you choose another processor, like the Uno, Pro Mini, Nano, etc.

You may find this helpful: ATtiny 85 and SPI

1 Like

I was just reading that post and I was able to make the connection in the same way. . thank you very much for your help.

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