Hello! im really new on this. i cant get this done. can anyone help me?
Attaching a .jpeg
You need to learn how to program in C, ... get a c or c++ tutorial
if (condition) {
.....
} else {
....
}
( Copying an image of your code is not a best practice... please read the posts at the top of the forum on how to post questions)
#include <Button.h>
int diod=13;
Button ledOn(4);
void setup() {
pinMode(13, OUTPUT);
ledOn.begin();
}
void loop() {
if (ledOn.pressed())
digitalWrite(diod, HIGH);
Serial.println("lampa");
else
digitalWrite(diod, LOW);
Serial.println("ingen");
}
i get this
error: 'else' without a previous 'if'
else
^
exit status 1
'else' without a previous 'if'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
You need two sets of curly brackets but it is hard to explain where in a photograph.
To post code and/or error messages:
Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.
If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.
Good Luck!
Have you read #1?? I gave you the correct syntax for an if else including many statements. you need to use {}.
Fix that and fix your code posts above by adding the code Tags. Your code should look like this
// your code here