Super beginner's question- does arduino work live with new inputs?

I'm well aware that this is probably a super silly beginner's question, but I want to understand- so please bear with me.

I read that the 'functions' subgroup in the arduino language is for controlling the arduino board and 'performing computations'.

Does that mean that arduino can work live with new inputs or must they all be defined beforehand? Or must a domain of possible values be defined? In turn does that mean that all inputs for arduino are converted into values? For example, is pressing a button assigned a certain value?

Hope this makes sense, I'd be happy to clarify. Thank you!

The "Arduino language" is C++.

If you understand C++, you can figure out how to read a pin or an ADC or write to a pin.

Yup, I get that arduino language is C++. I haven't understood it fully as of now, but I'm just interested in how it would work in theory. Thank you!

Hi,

Does that mean that arduino can work live with new inputs Yes

or must they all be defined beforehand? Or must a domain of possible values be defined? No (is the same question twice?)

In turn does that mean that all inputs for arduino are converted into values? For example, is pressing a button assigned a certain value? Yes

Regards

Banana28: I read that the 'functions' subgroup in the arduino language is for controlling the arduino board and 'performing computations'.

well functions are a construct of C++ and many programming languages. What you do in a function is defined by the code you put in there. they can "control" the board (eg read or set pins) or do other stuff like calculate something.

Banana28: Does that mean that arduino can work live with new inputs or must they all be defined beforehand? Or must a domain of possible values be defined?

Your program will need to look at what "input" it gets (reading the pins or using higher level abstractions such as Serial or other types of Communication protocol exchanging data) and do something with that information. if the code can handle random stuff, then you'll have flexibility, if you only recognize one type of input, then you are more limited. the code you upload in the Arduino is what defines the capabilities.

Banana28: In turn does that mean that all inputs for arduino are converted into values? For example, is pressing a button assigned a certain value?

What you describe is at a higher level of abstraction. at hardware level - and if things are wired in the right way - pressing a button will change a pin voltage to LOW or HIGH.

if your program happens to check the voltage on that pin at that moment, then the code will know the status of the pin and you can decide what to do in the code.

There are libraries abstracting the lower level if you don't want to bother with that part at this stage, so if you take a button library you can define a button object connected to a pin and tell that object to trigger a specific function when the button is pressed. What you see when programming with such an Object is hiding (abstracting) the hard reality of checking pin values, dealing with bouncing etc which still happens for you.

--> would suggest you learn the basics of programing in C and C++ and perform a few basic Arduino tutorials; Everything then will become much clearer.

The short answer is "Yes and No" to each of all three options.

The Arduino can deal with a situation where a domain of possible values is pre defined (effectively a simulator)

The Arduino can cope with new live input values. All inputs must be defined beforehand

Pressing a button does get assigned a value. The value, however, is decided by the programmer at the time of coding the software.

The theory, in short, is Have an idea for a project -> determine the hardware required -> design a circuit -> plan and design software -> write C/C++ code for an Arduino (and any other microcontroller associated with the project) -> test

To get more of an idea about the concept, have a look at the Guide. Wikipedia also has an article on the concept.

This is an extremely interesting question for beginners to understand coding. The Arduino and C/C++ are not intrinsically ‘event driven’ like a multi-tasking OS.

A good example is the ongoing conversation about delay() and millis()... the first allows you to ‘stall everything’ for a period, while the latter provides a resource which allows you to determine ‘when’ things might happen. These are similar in what you achieve, but totally different in how they affect the surrounding program.

You can create ‘event’ driven procedures, but due to several limitations of a small platform’s hardware, it is more common to poll the pins and peripherals i. as a very tight application of the available resources.