I have seen it somewhere, where you place some of the most used input stuff at the beginning of a Script, that will get done as the Script gets done. Thanks
Do you have a question?
I am sorry for not writing, what I thought was my question about ARDUINOS - what I am trying to find out is what is to be written in a SCRIPT, that is used in the SETUP of the SCRIPT, - there is the BEGINING of a SCRIPT that is used in the main setup, that is used many time in one SCRIPT.
????? Variables, I think it may be, then there is the SETUP, that some of the VARIABLES do something and there is still more VARIABLES later in the SETUP.
MY IDEA of a SCRIPT is the following, if these variable are written at the START, that later do something in the 1st part of the SCRIPT, may be the middle of the Script and maybe at the end.
if these variable are preset at the beginning, later in the Script something gets done - IF THIS HAPPENS SOMETHING HAPPEN, at the beginning, middle and end., I am now sure THEY ARE CALLED VARIABLE, but could be wrong. THANKS FOR YOUR TIME.
Hopefully somebody can recommend a book/website or a book/website with a "starter kit".
The Arduino is one of the best/easiest ways to get started with programming, but it's "hardware" and you generally have to learn some electronics at the same time (if you don't already know some electronics.)
I can't recommend anything because I learned the basics long ago and I was able to study and learn about the Arduino by myself. And in fact my 1st programming class wasn't very good... They taught the programming language without explaining the concepts or terminology. I mostly figured that stuff out on my own. Most computer books also skip the basics and jump-into the particular programming language.
BTW - The best way to learn anything is by taking a class. Most professional programmers take programming in college and have Computer Science degrees or some other technical degree. But most Arduino hobbyists learn on their own.
"Step 1" or (step zero) is learning the "big picture"... What programming is all about... The terminology, what programs are, variables, loops, conditional execution. etc.
A "program" is a set of instructions for the computer. Sometimes Arduino programs are called "sketches". A "script" is usually a program that doesn't need to be complied (like a 'programmed" sequence of operating system instructions to copy files, etc.) or it might be a program that's complied or interpreted every time you run it.
Sometimes we call it "code". An Arduino program (sketch) contains C++ language "code".
If you look at the Blink Example the program (the "code") is in the box. It's written in a special Arduino variation of C++. (1)
The first thing you see is a long comment. Comments are for humans and they are ignored by the compiler and the don't exist in the machine language compiled "binary" or "hex" code that's loaded into the Arduino.
/*
This is a comment.
It's notes/information for humans.
It's for other programmers or to remind yourself if you come back and modify the program later.
*/
// This is also a comment
The program runs (executes) in sequence.
setup() runs first and then the loop().
The main loop runs over-and-over forever. Most Arduino programs have a main "infinite loop".
You can have other loops inside the main loop that run until some condition is met, and then execution continues to the next instruction in the main loop (nested loops).
There are no variables in the Blink Example, but we could make one like this:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
int delayTime = 1000; // THIS IS A VARIABLE INITIALIZED FOR 1000ms (1 second)
// I could have named it anything, except I can't name it "delay" because delay is already defined as a function built-into the Arduino language.
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(delayTime); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(delayTime); // wait for a second
delayTime = 500; // Change the delay to 1/2 second after the 1st time through the loop
}
(1) Standard C++ can read a keyboard or write to a file on your hard drive, etc. These things don't work with the Arduino because it doesn't come with a keyboard or hard drive, And the Arduino language has functions to read/write input/output pins that don't exist on a regular computer.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.