I'm new with arduino and I wrote one of my first code. This code is meant to change the powered LEDs combinations (for example 1,2 on, 3,4 off) but it doesn't work... Do you know what's the problem?
The code:
int pin = 0;
// the Voids named with letters are actually combinations
// a for example lights on only the first LED
// n lights on first and last LED
//and so on
void a(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
}
void a2(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(2, HIGH);
}
void c(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
pinMode(2, HIGH);
}
void e(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(3, HIGH);
}
void h(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
pinMode(3, HIGH);
}
void i(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(2, HIGH);
pinMode(3, HIGH);
}
void l(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
pinMode(2, HIGH);
pinMode(3, HIGH);
}
void m(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(4, HIGH);
}
void n(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
pinMode(4, HIGH);
}
void o(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(2, HIGH);
pinMode(4, HIGH);
}
void r(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
pinMode(2, HIGH);
pinMode(4, HIGH);
}
void t(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(3, HIGH);
pinMode(4, HIGH);
}
void w(){
for (int i;i<5;i++) pinMode(i, LOW);
pinMode(1, HIGH);
pinMode(3, HIGH);
pinMode(4, HIGH);
}
void setup() {
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(7, INPUT); //here is the button for changing
Serial.begin(9600);
}
void loop() {
Serial.println(digitalRead(7));
if (digitalRead(7) == 1){
if (pin==0)
for (int i;i<10;i++){
pinMode(1, HIGH);
pinMode(2, HIGH);
pinMode(3, HIGH);
pinMode(4, HIGH);
delay(1000);
pinMode(1, LOW);
pinMode(2, LOW);
pinMode(3, LOW);
pinMode(4, LOW);
delay(1000);
}
if (pin==1) a;
if (pin==2) a2;
if (pin==3) c;
if (pin==4) e;
if (pin==5) h;
if (pin==6) i;
if (pin==7) l;
if (pin==8) m;
if (pin==9) n;
if (pin==10) o;
if (pin==11) r;
if (pin==12) t;
if (pin==13) w;
if (pin==14) pin = 0;
pin++;
delay(2000);
}
}