ok, i got the code from Nick G. to compile and load onto tiny85.
my situation now is understanding the pinouts cause nothing working through SPI function. (3wire SPI)
i can do seperate code to get SS pin to go high/low so i know the buttons work. i can not get the MCP41100 to respond testing on LED.
my pinouts are as follows:
my MCP pinout to tiny85
1 - CS (SS tiny85 D3) 8 - VCC
2 - SCK (tiny85 D2) 7 - POT GND
3 - SI (tiny85 D0) 6 - wiper (to test LED)
4 - GND 5 - POT input (+5V)
code setup in Nick's namespce:
// +-/-+
// RESET Ain0 (D 5) PB5 1| |8 Vcc
// CLK1 Ain3 (D 3) PB3 2| |7 PB2 (D 2) Ain1 SCK / USCK / SCL
// CLK0 Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1 MISO / DO
// GND 4| |5 PB0 (D 0) pwm0 MOSI / DI / SDA
// +----+
const byte DI = 0; // D0, pin 5 Data In
const byte DO = 1; // D1, pin 6 Data Out (this is not MOSI)
const byte USCK = 2; // D2, pin 7 Universal Serial Interface clock
const byte SS = 3; // D3, pin 2 Slave Select
am i just not seeing what i am doing wrong? i emailed Nick and his comment says my pinouts do match the code
I note however that your pinouts do not agree at all with my code. You have:
for test purposes, i have pot connected to LED instead of headphone input.
i connected to same pin labels as i used on 328P and d. pot works but i know T-85 is different.
Tiny85 pins
1 - empty
4- GND
8 - +5V
6 - empty
MCP41100 Tiny85
1 - CS conected to >>>>>> D3/pin 2
2 - SCK conected to >>>>>> D2/SCK/pin 7
3 - SI conected to >>>>>> D0/MOSI/pin 5
4 - GND
5 - INPUT (headphone input)
6 - WIPER ( to amp)
7 - GND
8 - +5V
// Written by Nick Gammon
// March 2013
// ATMEL ATTINY45 / ARDUINO
//
// +-\/-+
// RESET Ain0 (D 5) PB5 1| |8 Vcc
// CLK1 Ain3 (D 3) PB3 2| |7 PB2 (D 2) Ain1 SCK / USCK / SCL
// CLK0 Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1 MISO / DO
// GND 4| |5 PB0 (D 0) pwm0 MOSI / DI / SDA
// +----+
namespace tinySPI
{
const byte DI = 0; // D0, pin 5 Data In
const byte DO = 1; // D1, pin 6 Data Out (this is *not* MOSI)
const byte USCK = 2; // D2, pin 7 Universal Serial Interface clock
const byte SS = 3; // D3, pin 2 Slave Select
void begin ()
{
digitalWrite (SS, HIGH); // ensure SS stays high until needed
pinMode (USCK, OUTPUT);
pinMode (DO, OUTPUT);
pinMode (SS, OUTPUT);
USICR = bit (USIWM0); // 3-wire mode
} // end of tinySPI_begin
// Clock out 8 bits. We write to USICR 16 times, because we need 16
// toggles of the clock (on/off/on/off etc.) but only 8 shifts.
// Thus first we clock, then we clock-and-shift.
// The data is valid on the clock leading edge (equivalent to CPHA == 0).
const byte toggleClock = bit (USIWM0) | bit (USICS1) | bit (USITC);
const byte toggleClockAndShift = bit (USIWM0) | bit (USICS1) | bit (USITC) | bit (USICLK);
byte transfer (const byte b)
{
USIDR = b; // byte to output
USICR = toggleClock; // MSB
USICR = toggleClockAndShift;
USICR = toggleClock;
USICR = toggleClockAndShift;
USICR = toggleClock;
USICR = toggleClockAndShift;
USICR = toggleClock;
USICR = toggleClockAndShift;
USICR = toggleClock;
USICR = toggleClockAndShift;
USICR = toggleClock;
USICR = toggleClockAndShift;
USICR = toggleClock;
USICR = toggleClockAndShift;
USICR = toggleClock; // LSB
USICR = toggleClockAndShift;
return USIDR; // return read data
} // end of tinySPI_transfer
} // end of namespace tinySPI
[color=maroon]int BS = A2; // resistor ladder input
int k = 128; // sets digital pot to 50%
void setup()
{
tinySPI::begin();
pinMode(BS,INPUT);
}
void loop()
{
int BR;
int i;
int j;
BR=analogRead(BS);
// raise volume with button press
if (BR<80 && BR>70)
{
k=k+2;
digitalWrite(tinySPI::SS,LOW);
tinySPI::transfer(k);
digitalWrite(tinySPI::SS,HIGH);
delay(100);
}
// lower volume with button press
if (BR<200 && BR>180)
{
k=k-2;
digitalWrite(tinySPI::SS,LOW);
tinySPI::transfer(k);
digitalWrite(tinySPI::SS,HIGH);
delay(100);
}
You are writing one byte to the pot to set its value?
From the datasheet (section 5), it looks like you need to send a command byte first, to say that you are about to send a pot value and (if you have the dual pot chip) select the pot you want to control.
i did read that part in the datasheet but i thought that was already being done through Nick's code for sending command byte first.
i also had to switch from pin 5 to pin 6 on the T-85.
tried several scenarios with values and all work as programmed.
the only thing i notice weird is as i hold button to raise or lower, the led flashes bright about every second and continues. does not do while button depressed.
i will try with the audio input next and see if that may be something to finish pulling my hair out.
THANK YOU VERY MUCH.
now i have something to work with and try to blow a few components. LOL
i also had to switch from pin 5 to pin 6 on the T-85.
The Data Output (DO) pin is on digital pin 1 (D1).
While Data Input (DI) is on digital pin 0 (D0).
And DO is also labelled MISO, on the assumption that the ATtiny will normally be the slave.
My head hurts
Hi there!
I have created a development board for attiny85 but the thing here is that i have design and 3 other shield to coorporate with the chip...
All the shield are 4 and compinning them together you will not need to add anything else(module,buttons etc).
A very nice project that i decided to put on indiegogo
please if you found it usefull help me make it happen...