I'm just starting to learn Arduino's and its coding but with all learning experience's I've hit a road block that i need some help. I'm been trying to do small projects to learn the process and code, currently i'm trying to use a meat thermometer and read it with the Arduino using some sample code. All was going good until i got to this line
result=Math.log(((10240000/x) - 10000));
I'm getting a "math was not declared in this scope error. My research says that i need math.h library but i can't find it. I tried defining it but it still didn't work I'm sure this is some rookie error.
Are you trying to covert code from some other language? "Math.log()" looks to be mostly a Javascript or Python syntax.
The C/C++ syntax would be more like "Math::log()", except that C/C++ is so old a language that math functions are shoved in at the "top level" of the namespaces, so it's just "log()"
(In this case "Math" is known as a 'namespace' that groups a bunch of similar functions, and prevents their names from conflicting with similar names that do something entirely different (say: "TinkerToyGraphics.log(length, diameter)") "Modern Languages" are big on using this concept as they embrace a broad range of "things." But C is not a "modern language", and (mathematical) log() is a standard C function.)
Thanks Westfw, that's helpful and makes some sence. Like is said, i'm trying to learn but it didn't look familiar. The post that i was using as a guide is here-
It looks to me like that particular example is a javascript host-side example talking to a Firmata sketch running on the arduino hardware. Huh. I just mentioned Firmata in another thread - it's a special purpose sketch/protocol that runs on both the arduino and the host (PC) that lets a host program (written in any number of languages) access the arduino hardware in ways that are similar to running code on the arduino itself (digitalWrite(), and etc.)