[![Roboti](../images/roboti-cover.jpg)](http://www.martinus.sk/?uItem=189767)
![We are Makers](http://s3files.core77.com/blog/images/2013/07/WeAreMakers-hero.jpg)
![Makers Faire - Namakaný deň 2019](../images/makers.fare-namakany.den.jpg)
## Sense-Think-Act Cycle
![Sense-Think-Act Cycle](../images/sense-think-act.png)
## Sensor
Converts other form of energy into electrical energy
## Actuator
Converts electrical energy into other form of energy
## Microcontroller
Small computer, which reacts with actuators to info gathered from sensors.
![Airplane](../images/airplane.png)
Notes:
* https://dribbble.com/shots/462460-Vintage-Airplane
## Microcontroller
Small computer, which reacts with actuators to info gathered from sensors.
![ATmega328P](../images/atmega.types.jpg)
notes:
* https://store.techmaze.ae/store/product/99188343
![Arduino Uno](../images/arduino-board.png)
[![Arduino IDE](../images/arduino.ide.png)](https://www.arduino.cc/en/Main/Software)
> The core libraries are written in C and C++ and compiled using ```avr-gcc```
![Blink Animation](../images/arduino-blink.gif)
notes:
* https://thestempedia.com/tutorials/program-arduino-board-with-pictoblox/
## Sketch Structure
```cpp
void setup(){
// initialization function
// runs once
}
void loop(){
// main loop
// runs continuously
}
```
## Hidden (?!) ```main()```
```cpp
int main(){
// runs once
setup();
// runs continuosly
for(;;){
loop();
}
}
```
## Cost of Sketch
```
Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
```
![System Architecture](../images/neuman.vs.harvard.architecture.png)
notes:
* https://vivadifferences.com/wp-content/uploads/2019/10/Von-Neuman-Vs-Harvard-Architecture.png
![The Memory Map of an ATmega328P](../images/atmega328p-memory.map.jpg)
Notes:
* https://www.arduino.cc/en/tutorial/arduinoISP
![SRAM Memory Usage](../images/atmega328p-sram.jpg)
notes:
* https://www.leonardomiliani.com/en/2013/la-memoria-sram-dei-microcontrollori/
![Memory Fragmentation](../images/memory.fragmentation.png)
Notes:
* https://blog.learngoprogramming.com/a-visual-guide-to-golang-memory-allocator-from-ground-up-e132258453ed
## Rules for Effecive Memory Usage
1. use stack instead of heap whenever possible
2. avoid using global and static data whenever possible
3. keep strings as short as possible
4. keep minimal length of arrays
5. use appropriate types for variables/fields
Programovanie pre Arduino môže byť aj celkom dobrým cvičením písania efektívneho kódu pre skúsených programátorov.
(Štepán Bechynský)
## [.kkrieger](https://en.wikipedia.org/wiki/.kkrieger)
96k game competition winner in 2004
([download](http://web.archive.org/web/20110717024227/http://kk.kema.at/files/kkrieger-beta.zip))