Unspecified code problem

Hello, Text preformatatI don't knowText preformatat why my code isn't working?`

void setup() {
// put your setup code here, to run once:
pinMode( 2, OUTPUT);
pinMode( 4, OUTPUT);

pinMode( 13, OUTPUT);
pinMode( 12, OUTPUT);
pinMode( 11, OUTPUT);
}

void loop() {
if(digitalRead(2)==HIGH);
{
digitalWrite(11,HIGH);
delay(2000);
digitalWrite(11,LOW);

digitalWrite(12,HIGH);
delay(2000);
digitalWrite(12,LOW);

digitalWrite(11,HIGH);
delay(2000);
digitalWrite(11,LOW);
}
{
if else {

}
{
digitalWrite(11,Low);
}
if( digitalWrite(4)== HIGH);{
digitalWrite(13,HIGH);
delay(2000);
digitalWrite(13,LOW);

digitalWrite(12,HIGH);
delay(2000);
digitalWrite(12,LOW);

digitalWrite(11,HIGH);
delay/(2000);
digitalWrite(HIGH);

}

if else {
digitalWrite(13,LOW);

}

{

}

}

@fhjp ,

Topic split from another topic. Please do not add your own questions to the end of other people's topics.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

I gave your topic a vague title because your question is vague and I couldn't think of anything better, you can edit it to something better.

Thank you.

1 Like

Try to strip off the delays.

Or perhaps use shorter times, like delay( 100 );

What is this supposed to do?

1 Like

Maybe digitalRead?

And get rid of the ;

Probably should be INPUT.

You are supposed to compile your code and fix the indicated errors...
Like Low...

Sorry I cannot read the gibberish you posted. Follow @PerryBebbington link and learn how to do it properly. Unspecified code problem apparently that is what the gibberish is? What Arduino are you using? what is the code suposto do, what part does it not do what you want? What have you tried? etc? If there is hardware post an annotated schematic.

I don't know how to writre else and if

El dc., 22 de maig 2024, 21:23, gilshultz via Arduino Forum <notifications@arduino.discoursemail.com> va escriure:

No google on your laptop?
Google C++ if else...

if (a==b) {
   do_something;
}
else {
    do_whatever_else;
}
1 Like

Thanks

El dc., 22 de maig 2024, 21:40, build_1971 via Arduino Forum <notifications@arduino.discoursemail.com> va escriure:

Be careful when you copy/paste from an HTML document. HTML does not copy correctly. You must verify the original and the "pasted" code are the same.

void setup() {
  // pinMode( 2, OUTPUT); // change to INPUT_PULLUP
  pinMode( 2, INPUT_PULLUP);
  // pinMode( 4, OUTPUT); // chenge to INPUT_PULLUP
  pinMode( 4, INPUT_PULLUP);

  pinMode( 13, OUTPUT);
  pinMode( 12, OUTPUT);
  pinMode( 11, OUTPUT);
}

void loop() {
  // if (digitalWrite(2) == HIGH)  { // this should be digitalRead(2) == LOW, remove semi-colon (;)
  if (digitalRead(2) == LOW)  { // remove semi-color (;)
    digitalWrite(11, HIGH);
    delay(2000);

    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    delay(2000);

    digitalWrite(12, LOW);
    digitalWrite(11, HIGH);
    delay(2000);

    digitalWrite(11, LOW);
    // remove extra braces and stray if else (nothing)
    digitalWrite(11, LOW);
  }

  // if( digitalWrite(4)== HIGH); { // this should be digitalRead() == LOW, remove semi-colon (;)
  if ( digitalRead(4) == LOW) {

    digitalWrite(13, HIGH);
    delay(2000);

    digitalWrite(13, LOW);
    digitalWrite(12, HIGH);
    delay(2000);

    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    delay(2000);

    digitalWrite(12, LOW); // add this line
    // digitalWrite(HIGH); // remove
    // if else { // remove
    digitalWrite(13, LOW);
  }
}
// remove extra braces

for WOKWI.COM

diagram.json
{
  "version": 1,
  "author": "Anonymous maker",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-nano", "id": "nano", "top": 0, "left": 0, "attrs": {} },
    {
      "type": "wokwi-pushbutton",
      "id": "btn1",
      "top": -41.8,
      "left": 163.2,
      "attrs": { "color": "green" }
    },
    {
      "type": "wokwi-led-bar-graph",
      "id": "bargraph1",
      "top": -120,
      "left": -42.8,
      "rotate": 180,
      "attrs": { "color": "lime" }
    },
    {
      "type": "wokwi-pushbutton",
      "id": "btn2",
      "top": -89.8,
      "left": 163.2,
      "attrs": { "color": "green" }
    }
  ],
  "connections": [
    [ "nano:GND.2", "btn1:2.l", "black", [ "v0" ] ],
    [ "nano:2", "btn1:1.l", "green", [ "v0" ] ],
    [ "nano:GND.2", "btn2:2.l", "black", [ "v0" ] ],
    [ "nano:4", "btn2:1.l", "green", [ "v0" ] ],
    [ "nano:13", "bargraph1:A1", "green", [ "v14.4", "h-19.7", "v-115.2" ] ],
    [ "nano:12", "bargraph1:A2", "green", [ "v0" ] ],
    [ "nano:11", "bargraph1:A3", "green", [ "v0" ] ],
    [ "bargraph1:C3", "bargraph1:C2", "green", [ "h0" ] ],
    [ "bargraph1:C2", "bargraph1:C1", "green", [ "h0" ] ],
    [ "nano:GND.2", "bargraph1:C1", "black", [ "v-14.4", "h-163.7" ] ]
  ],
  "dependencies": {}
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.