hi.I want to make KNIGHT RIDER.i write LedOff() function to turn off leds.it work well.but i cant write LedsOn() function please help me.I want something like this
LedsOn(2); led 2 turns on
LedsOn(2,3); led 2 and led 3 turns on
LedsOn(2,3,4,5,6,7); led 2,3,4,5,6,7 turns on
this code work fine
int pinArray[] = {6, 10, 13,};
void setup(){
for (int count=0;count<3;count++) {
pinMode(pinArray[count], OUTPUT);
}
}
void loop() {
digitalWrite(6, HIGH);
delay(1000);
LedsOff();
digitalWrite(6, HIGH);
digitalWrite(10, HIGH);
delay(1000);
LedsOff();
digitalWrite(6, HIGH);
digitalWrite(10, HIGH);
digitalWrite(13, HIGH);
delay(1000);
LedsOff();
digitalWrite(13, HIGH);
delay(1000);
LedsOff();
digitalWrite(10, HIGH);
delay(1000);
LedsOff();
digitalWrite(6, HIGH);
delay(1000);
LedsOff();
}
void LedsOff(void)
{
for (int count=0;count<3;count++) {
digitalWrite(pinArray[count], LOW);
}
}
but in this code i get error INVALID CONVERSION FROM ‘INT’ to ‘int*’
int pinArray[] = {6, 10, 13,};
void setup(){
for (int count=0;count<3;count++) {
pinMode(pinArray[count], OUTPUT);
}
}
void loop() {
LedsOn(6);
delay(1000);
LedsOff();
LedsOn(6,10);
delay(1000);
LedsOff();
LedsOn(6,10,13);
delay(1000);
LedsOff();
}
void LedsOff(void)
{
for (int count=0;count<3;count++) {
digitalWrite(pinArray[count], LOW);
}
}
void LedsOn(int pinAray[3])
{
for (int counts=0;counts<3;counts++) {
digitalWrite(pinAray[counts], HIGH);
}
}