Hi there, I am working on running a sketch written for arduino on an ATTINY85v. Thanks to the help from Coding Badly in my previous thread, I was able to transfer the sketch to the ATTINY85v successfully. Arduino Forum
My issue though is that the sketch does not do what it is supposed to do at all. I have 3 LED's hooked up to physical pins 4,5,and 6 of the ATTINY, and yet only one of the LED's light up, and it just either stays on all the time or it blinks. I thought that I was using code that was compatible with the ATTINY, but maybe I have overlooked something. I tried different MHz speeds for the ATTINY and still no luck.
Any idea why this is not working properly on an ATTINY?
some of the arrays have been removed due to exceeding the word limit for posts
long lastTime = 0;
const int RPIN = 0;
const int GPIN =1;
const int BPIN =4;
const int SWITCHPIN = 2;
int countArray[] = {200,125,200,18,23,72,8};
int maxSwitch = 9;
int currentPlace = 0;
int count = 0;
boolean pressed = false;
boolean rArray0[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
boolean gArray0[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
boolean bArray0[] = {255,255,255,255,100,100,100,100,100,255,255,255,255,100,100,100,100,100};
int hArray0[] = {0,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50};
/*omit
boolean rArray5[] = {1,0,1,0,1,1,1,1,0,1,0,1,1,1};
boolean gArray5[] = {1,1,1,0,1,0,1,1,1,1,0,1,0,1};
boolean bArray5[] = {1,0,1,1,1,0,1,1,0,1,1,1,0,1};
int hArray5[] = {34,34,34,34,34,34,34,34,34,34,34,34,34,34};
*/
/* omit
boolean rArray7[] = {1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0};
boolean gArray7[] = {0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1};
boolean bArray7[] = {0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0};
int hArray7[] = {75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75};
*/
boolean rArray3[] = {127,0,0,100,0,0,127,0,0,100,0,0,127,0,0,100,0,0};
boolean gArray3[] = {0,0,127,0,0,100,0,0,127,0,0,100,0,0,127,0,0,100};
boolean bArray3[] = {0,127,0,0,100,0,0,127,0,0,100,0,0,127,0,0,100,0};
int hArray3[] = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25};
boolean rArray4[] = {0,127,0,100,100,100,0,0,0,100,100,0,0,127,0,0,127,0,100,100,100,0,100};
boolean gArray4[] = {0,0,127,100,0,0,100,100,0,127,0,100,100,0,100,100,100,100,100,0,100,100,100};
boolean bArray4[] = {100,100,100,0,127,0,0,100,100,100,100,0,100,100,0,127,0,127,0,100,100,0,127};
int hArray4[] = {20,50,25,20,25,25,30,50,20,20,50,32,25,20,35,50,30,25,30,25,20,30,50};
boolean rArray5[] = {100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0};
boolean gArray5[] = {0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100};
boolean bArray5[] = {0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0,0,100,0};
int hArray5[] = {0,250,250,250,250,250,250,250,250,250,250,250,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25};
boolean rArray6[] = {100,127,0,0,0,100,0,127,100,0};
boolean gArray6[] = {0,0,0,100,127,0,0,100,0,0};
boolean bArray6[] = {100,0,127,0,100,0,127,0,100,127};
int hArray6[] = {500,500,500,500,500,500,500,500};
//boolean mRArray[] = {rArray1[],rArray2[]}; 1+10+10+11=32 array0
//boolean mGArray[] = {gArray1[],gArray2[]};
//boolean mBArray[] = {bArray1[],bArray2[]};
void setup(){
Serial.begin(9600);
pinMode(RPIN,OUTPUT);
pinMode(GPIN,OUTPUT);
pinMode(BPIN,OUTPUT);
pinMode(SWITCHPIN,INPUT);
// pinMode(SPEEDPOT,INPUT);
}
void checkBtn(){
boolean switcher = digitalRead(SWITCHPIN);
if(!pressed && switcher){
pressed = true;
currentPlace++;
count = 0;
lastTime = millis();
}
if(pressed && !switcher){
pressed = false;
}
}
void loop(){
checkBtn();
if(lastTime == 0){
lastTime = millis();
}
//POTvalue = analogRead(SPEEDPOT);
/////////////////////////////////
if(lastTime + count < millis() && currentPlace == 0){
hArray0[count];
analogWrite(RPIN,rArray0[count]);
analogWrite(GPIN,gArray0[count]);
analogWrite(BPIN,bArray0[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
//////////////////////////
if(lastTime + count < millis() && currentPlace == 1){
hArray1[count];
analogWrite(RPIN,rArray1[count]);
analogWrite(GPIN,gArray1[count]);
analogWrite(BPIN,bArray1[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
/////////////////////////////////
if(lastTime + count < millis() && currentPlace == 2){
hArray2[count];
analogWrite(RPIN,rArray2[count]);
analogWrite(GPIN,gArray2[count]);
analogWrite(BPIN,bArray2[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
///////////////////////////
if(lastTime + count < millis() && currentPlace == 3){
hArray3[count];
analogWrite(RPIN,rArray3[count]);
analogWrite(GPIN,gArray3[count]);
analogWrite(BPIN,bArray3[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
///////////////////////////
if(lastTime + count < millis() && currentPlace == 4){
hArray4[count];
analogWrite(RPIN,rArray4[count]);
analogWrite(GPIN,gArray4[count]);
analogWrite(BPIN,bArray4[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
///////////////////////////
if(lastTime + count < millis() && currentPlace == 5){
hArray5[count];
analogWrite(RPIN,rArray5[count]);
analogWrite(GPIN,gArray5[count]);
analogWrite(BPIN,bArray5[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
///////////////////////////
if(lastTime + count < millis() && currentPlace == 6){
hArray6[count];
analogWrite(RPIN,rArray6[count]);
analogWrite(GPIN,gArray6[count]);
analogWrite(BPIN,bArray6[count]);
lastTime = millis();
count = count + 1;
if(count >= countArray[currentPlace]){
count = 0;
}
}
if(currentPlace >= maxSwitch){
currentPlace = 0;
}
Serial.println (POTvalue);
}