68Views0Replies

Author Options:

ArduinoISP Does Not Support PORT Commands? Answered

I was planning to make a drum machine that only requires two pins on the Arduino and so, wanted to use an AtTiny85v but it gives me errors like:

'DDRD' was not declared in this scope

ArduinoBeats.cpp: In function 'void setup()':
ArduinoBeats:97: error: 'DDRD' was not declared in this scope
ArduinoBeats.cpp: In function 'void playKick()':
ArduinoBeats:288: error: 'PORTD' was not declared in this scope
ArduinoBeats:294: error: 'PORTD' was not declared in this scope
ArduinoBeats.cpp: In function 'void playSnare()':
ArduinoBeats:304: error: 'PORTD' was not declared in this scope
ArduinoBeats:310: error: 'PORTD' was not declared in this scope
ArduinoBeats.cpp: In function 'void playHat()':
ArduinoBeats:320: error: 'PORTD' was not declared in this scope
ArduinoBeats:326: error: 'PORTD' was not declared in this scope
ArduinoBeats.cpp: In function 'void playCrash()':
ArduinoBeats:335: error: 'PORTD' was not declared in this scope
ArduinoBeats:341: error: 'PORTD' was not declared in this scope

I had named the sketch ArduinoBeats so that explains all the ArduinoBeats stuff. Does anybody know how to add this command to the AtTiny library? Any help would be appreciated.






Here is the code from Little Scale:


/* Arduino Beats

by Sebastian Tomczak

6 April 2008

*/


// Working Variables


byte byteA;

byte byteB;

int delayTime = 100;

int barLength = 16;


// Beats


byte bar1[] = {

1, 0, 1, 0, 2, 4, 1, 2, 1, 0, 1, 0, 2, 1, 3, 0

};


byte bar2[] = {

1, 0, 1, 0, 2, 0, 1, 2, 1, 0, 1, 0, 2, 2, 2, 2

};


byte bar3[] = {

1, 3, 1, 3, 2, 3, 1, 2, 1, 3, 1, 2, 1, 1, 4, 4

};


byte bar4[] = {

1, 0, 1, 0, 2, 2, 0, 2, 2, 1, 1, 4, 1, 1, 4, 4

};



// Samples


byte kick[] =

{

127, 80, 42, 5, 165, 242, 241, 233, 128, 73, 48, 22, 127, 69, 55, 113, 151, 183, 209, 217, 223, 228, 233, 215, 161, 117, 91, 76, 65, 49, 37, 31, 31, 48, 83, 120, 146, 166, 183, 198, 206, 210, 209, 199, 178, 145, 111, 88, 78, 73, 69, 67, 72, 80, 88, 97, 109, 124, 137, 150, 163, 171, 174, 172, 168, 160, 144, 125, 114, 110, 108, 104, 104, 106, 109, 110, 112, 117, 124, 129, 135, 142, 145, 145, 143, 140, 137, 132, 128, 125, 122, 119, 118, 119, 119, 119, 118, 118, 120, 124, 126, 129, 132, 135, 137, 137, 135, 132, 131, 130, 129, 128, 126, 126, 124, 123, 121, 120, 120, 122, 123, 124, 126, 128, 129, 130, 130, 131, 131, 131, 130, 130, 130, 129, 129, 128, 126, 125, 125, 124, 124, 124, 124, 125, 126, 126, 128, 128, 128, 129, 129, 129, 129, 129, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 127, 126, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126

};


byte snare[] =

{

127, 215, 65, 212, 56, 102, 135, 122, 51, 201, 220, 46, 175, 80, 152, 95, 123, 116, 184, 155, 59, 122, 100, 161, 143, 173, 101, 155, 97, 73, 112, 98, 176, 96, 140, 77, 134, 109, 132, 149, 112, 149, 97, 161, 98, 151, 98, 155, 149, 112, 157, 103, 133, 106, 167, 97, 166, 108, 129, 124, 136, 146, 124, 136, 129, 150, 94, 130, 105, 141, 146, 128, 129, 99, 150, 121, 141, 99, 142, 116, 131, 114, 118, 143, 127, 143, 115, 144, 120, 137, 109, 129, 131, 139, 129, 113, 144, 119, 145, 117, 135, 129, 134, 136, 124, 130, 130, 139, 121, 136, 121, 132, 128, 127, 126, 122, 130, 126, 138, 120, 136, 122, 131, 123, 130, 128, 127, 128, 118, 132, 125, 131, 122, 131, 125, 131, 122, 126, 128, 126, 129, 121, 129, 123, 132, 129, 127, 131, 123, 128, 125, 130, 123, 131, 123, 128, 131, 129, 128, 126, 125, 124, 131, 121, 124, 129, 130, 126, 124, 126, 127, 130, 125, 126, 128, 126, 128, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 126, 128, 126, 127, 126, 128, 125, 127, 128, 128, 126, 126, 128, 126, 126, 128, 128, 128, 128, 128, 126, 128, 126, 126, 128, 128, 126, 126, 128, 128, 126, 126, 127, 126, 128, 126, 126, 128, 128, 128, 126, 126, 126, 128, 128, 126, 126, 126, 128, 128, 126, 128, 128, 126, 126

};


byte hat[] =


{

127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127

};


byte crash[] =


{

127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127

};



void setup() {

DDRD = DDRD | B11111100; //In attempt to try and use an ATtiny, I got an error here

}

void loop() {



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar2[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar3[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar2[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar1[j]);

}



for(int j = 0; j < barLength; j ++) {

playBeat(bar4[j]);

}




}



// Playback Functions


void playBeat(byte beat) {

if(beat == 0) {

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

delayMicroseconds(analogRead(0) + 1);

}

}



else if(beat == 1) {

playKick();

}

else if(beat == 2) {

playSnare();

}

else if(beat == 3) {

playHat();

}

else if(beat == 4) {

playCrash();

}

delay(delayTime);

}


void playKick() {

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

PORTD = kick[i];

delayMicroseconds(analogRead(0) + 1);

}

PORTD = 127;

}



void playSnare() {

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

PORTD = snare[i];

delayMicroseconds(analogRead(0) + 1);

}

PORTD = 127;

}



void playHat() {

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

PORTD = hat[i];

delayMicroseconds(analogRead(0) + 1);

}

PORTD = 127;

}


void playCrash() {

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

PORTD = crash[i];

delayMicroseconds(analogRead(0) + 1);

}

PORTD = 127;

}


Discussions