I am using https://www.halvorsen.blog/, as advised.
Sketch_28a professes to be an instructable yet along with other sketches in this tutorial, it is not functioning as it should do, apparently. Even after me attempting to duplicate the code, from which I learn nothing, pixel by pixel for another failure. I have got really fed up with going through these examples that invariably come back with errors. There is one that reads
"pinMode(11, OUTPUT);"
I know that unless I change the layout of the board by adding an LED or changing 11 to 13, it will do nothing when uploaded.
I have thought that this is intentional so that I will endeavour to correct the faults and learn in the process. Alas, I have learned virtually nothing from these tutorials, replacing bad code for good code when I can is just
"parrot fashion"
to me. All this depends on where I go to get some help. This is all very disappointing, but nevertheless:
'average' was not declared in this scope. ...?
what does that mean? Why is it referred to as a scope?
Why does this tutorial, and others, talk, from the getgo about elements in the code as though I had been coached about pieces like
"int, Serial.begin(9600) etc. "
previous to me starting the tuts?
Why 9600? and how about
"float gjennomsnitt = 0"?
At no point does it state that I should know this and that before I start?
Please can someone help me out here? I have all this kit here but as usual in these forums, newbies are just skirted past for the most part?
PS Old "Scopes" that I have got working from this man's blog, now stick on uploading? More to worry about.
OK
The Code....
int x; int sum = 0; float gjennomsnitt = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
sum = 0;
for (int i = 0; i<100; i++)
{
x = random(100);
sum = sum + x;
}
average = sum / 100;
Serial.print(" Sum = ");
Serial.print(sum);
Serial.print(" , Average = ");
Serial.println(average);
delay(1000);
That is indeed failing at some places. He should have tested the examples.
Many code and libraries for Arduino is at Github.com, then someone can make an "Issue" and tell there is something wrong.
The "scope" is compiler talk. The compiler can not find the declaration of the "average" variable.
That doesn't make it a blog that the Arduino forum is responsible for.
Anyway here's your code fixed at least to compile, see the <<<<< line.
int x; int sum = 0; float gjennomsnitt = 0;
float average; // <<<<<<<<<<<<< you need this
void setup()
{
Serial.begin(9600);
}
void loop()
{
sum = 0;
for (int i = 0; i < 100; i++)
{
x = random(100);
sum = sum + x;
}
average = sum / 100;
Serial.print(" Sum = ");
Serial.print(sum);
Serial.print(" , Average = ");
Serial.println(average);
delay(1000);
}
Easiest way to post code is, in the ide, go control-t which does sexy indenting, then go edit > copy for forum (or control, shift, c) and then just control-v that into your post.
@cut-me-own-throat_dibbler - remember that 90% of the people in this forum are here to help rather than be know-it-all-dicks.
I don't know anything about the tutorial thing that you are doing.. but if you explain your specific problem clearly then there is an amazing amount of knowledge here to help you solve your problem.