Understanding Compilation Process and Arduino Programming

compilation n.w
1 / 13
Embed
Share

Dive into the compilation process, from preprocessing to linking, and explore Arduino programming with examples on button pull-up modes and LED control. Get insights on dynamic versus static linking and practical coding implementations.

  • Compilation
  • Arduino
  • Programming
  • Linking
  • Preprocessing

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Compilation .

  2. Compilation Preprocessor gcc -E code.c Compiler code gcc -S code.c Assembler gcc -c code.c Linker gcc code.c code.i code.S code.o code.exe

  3. . - Main.cpp - Rectangle.cpp: - Rectangle.hpp: header file

  4. Linker (entry point)

  5. Dynamic vs static Linking Static linking/ . (+) (-) + Arduino Dynamic linking / . (+) + (-) dll- hell arduino

  6. # this is sample main file .SILENT : main libadd.a Makefiles main : gcc_main.o libadd.a @echo "> Started building main.exe" gcc -o main.exe gcc_main.o -Lbin\static -ladd ( ) . ( Arduino). @echo "> Finished building main.exe gcc_main.o : software projects. @echo ">>>>>>>>>>>>>>>>>building gcc_main.o" gcc -c gcc_main.c -o gcc_main.o compile . libadd.a : add.c X 3. @echo ">>>>>>>>>>>>>>>>>building libadd.h" mkdir -p bin\static gcc -c add.c -o bin\static\add.o ar rcs bin\static\libadd.a bin\static\add.o clean : -rm main.exe -rm -rf bin/*

  7. Arduino (tinkercad) physical 2 . : to button pullup mode : global

  8. bool buttonState = 0; bool previousState = 1; long int prevTime = 0; bool flagMessageSent = 0; K void setup() { Serial.begin(9600); pinMode(2, INPUT_PULLUP); 2 : 1o void setup() void loop() pinMode(LED_BUILTIN, OUTPUT); } void loop() { buttonState = digitalRead(2); elegxoi (buttonState); previousState = buttonState; } 2o: void elegxoi() void elegxoi (int buttonState){ long int time = millis(); // check if pushbutton is pressed. if it is, the // buttonState is HIGH if (buttonState == LOW ) { // turn LED on digitalWrite(LED_BUILTIN, HIGH); if(previousState==HIGH){ prevTime = time; }else{ if(time-prevTime>=2000 && flagMessageSent==0){ Serial.println("To koumpi path8hike"); flagMessageSent = 1; } . 1o 2 } } else { // turn LED off //prevTime = time; flagMessageSent =0; digitalWrite(LED_BUILTIN, LOW); } }

  9. (ino, hpp) (loop, setup) Ino file #include other.hpp Other.hpp bool previousState = 1; long int prevTime = 0; bool flagMessageSent = 0; bool buttonState = 0; bool previousState = 1; void setup() { Serial.begin(9600); pinMode(2, INPUT_PULLUP); void elegxoi (int buttonState){ long int time = millis(); // check if pushbutton is pressed. if it is, the // buttonState is HIGH if (buttonState == LOW ) { // turn LED on digitalWrite(LED_BUILTIN, HIGH); if(previousState==HIGH){ prevTime = time; }else{ if(time-prevTime>=2000 && flagMessageSent==0){ Serial.println("To koumpi path8hike"); flagMessageSent = 1; } pinMode(LED_BUILTIN, OUTPUT); } void loop() { buttonState = digitalRead(2); elegxoi (buttonState); previousState = buttonState; } } } else { // turn LED off //prevTime = time; flagMessageSent =0; digitalWrite(LED_BUILTIN, LOW); } buttonState ? } ino elegxoi

  10. (ino, hpp) To cheating. include copy hpp ino. header files

  11. 3 arxeia other.hpp void elegxoi (int buttonState); Program.ino other.cpp #include <Arduino.h> #include "other.hpp #include other.hpp extern bool previousState; long int prevTime = 0; bool flagMessageSent = 0; bool buttonState = 0; bool previousState= 1; void elegxoi (int buttonState){ long int time = millis(); // check if pushbutton is pressed. if it is, the // buttonState is HIGH if (buttonState == LOW ) { // turn LED on digitalWrite(LED_BUILTIN, HIGH); if(previousState==HIGH){ prevTime = time; }else{ if(time-prevTime>=2000 && flagMessageSent==0){ Serial.println("To koumpi path8hike"); flagMessageSent = 1; } void setup() { Serial.begin(9600); pinMode(2, INPUT_PULLUP); pinMode(LED_BUILTIN, OUTPUT); } void loop() { buttonState = digitalRead(2); elegxoi (buttonState); previousState = buttonState; } } } else { // turn LED off //prevTime = time; flagMessageSent =0; digitalWrite(LED_BUILTIN, LOW); } }

Related


More Related Content