// ccontrolling 8 leds by a button
const int buttonPin = 12; //set pins
const int highPin = 9;
const int lowPin = 2;
void setup() {
pinMode(buttonPin, INPUT);//set button pin as input and set all led pins as outputs
for(int l = lowPin; l <= highPin; l++){
pinMode(l, INPUT);
}
}
void loop() {
if(buttonPin == HIGH){
for(int l = lowPin; l <= highPin; l++){
digitalWrite(l == HIGH);
}
}
else(buttonPin == LOW){
for(int l = lowPin; l >= highPin; l--){
digitalWrite(l == LOW);
}
}
}
it highlights digitalWrite(l == LOW) and says: too few arguments to function 'void digitalWrite(unit8_t, unit8_t)'
it highlights digitalWrite(l == LOW) and says: too few arguments to function
That's because you are trying to use the function incorrectly.
digitalWrite takes 2 arguments, the pin number to write to and the state to set it to. See digitalWrite() - Arduino Reference
thank you I am a beginner so this will help
ujwaljoshi:
// ccontrolling 8 leds by a button
(2)const int buttonPin = 12; //set pins
pinMode(buttonPin, INPUT);//set button pin as input and set all led pins as outputs
for(int l = lowPin; l <= highPin; l++){
(1) pinMode(l, INPUT);
...
(2) if(buttonPin == HIGH){
...
else(buttonPin == LOW){
it highlights digitalWrite(l == LOW) and says: too few arguments to function 'void digitalWrite(unit8_t, unit8_t)'
(1)Comment says led pins as output, but code says input.
(2)Buttonpin is always 12 and that is high, really no need to test for high or low.
You better try
(2) if (digitalRead(buttonpin)==HIGH){
Gabriel_swe:
(2)Buttonpin is always 12 and that is high,
Maybe 12 would be interpreted as not LOW, but it is definitely not equal to HIGH.