Go Down

Topic: Library Creation (Read 87 times) previous topic - next topic

StormBreaker06

Hi guys, I'm new in here, but old in arduino programming, but just no I had to create my own library for some reasons that are not important to say. But I have a question: when I put the library in the code, and upload the code, is guaranteed that the library is going together? P.s: the code is down here, and sorry for the bad english (I'm not a born speaker).
Code: [Select]

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "volante.h"
#include "marcha.h"
#include "rpm.h"
#include "myregister.h"

//Estruturas de #define vindos de marcha.ino:
#define store 21 //Regristrador de armazenamento
#define dataa  19 //Entrada de dados
#define shift 18 //Registrador de deslocamento
#define s1 4 // sensor 1 para marcha
#define s2 22 // sensor 2 para marcha
#define s3 1 // sensor neutro

//Estruturas de #define vindos de velocidade.ino:
#define REFRESH_TIME 1000

//Def. do LiquidCrystal:
#include "MyLiquidCrystal.h" //-->coloquei aqui aquele código doido que parecia estar definindo o "LiquidCrystal", para economizar espaço de trabalho de código

//Estruturas de vindos de volante.ino:
int potenciometro = A1;
int val_pot = 0;

void setup() {
//vindo de marcha.ino:
  Serial.begin(115200);
  pinMode(store, OUTPUT);
  pinMode(dataa,  OUTPUT);
  pinMode(shift, OUTPUT);
  pinMode(s1, INPUT);
  pinMode(s2, INPUT);
  pinMode(s3, INPUT);

//vindo de volante.ino:
  pinMode(potenciometro,INPUT);

//vindo de velocidade.ino:
  attachInterrupt(0, speedCalc, RISING);
  lcd.begin (20, 4);
  lcd.setBacklight(HIGH);
  Wire.begin();
  lcd.begin(20, 4);
  lcd.createChar(1, LT);
  lcd.createChar(2, UB);
  lcd.createChar(3, RT);
  lcd.createChar(4, LL);
  lcd.createChar(5, LB);
  lcd.createChar(6, LR);
  lcd.createChar(7, UMB);
  lcd.createChar(8, LMB);
  lcd.clear();
  loopCount = 0;
  lastRefresh = millis();
  speedk = 0.0;
  rpm = 0.0;
}

void loop() {
  Leitura_marcha(int s1,s2);
  analise_de_rpm();
  leitura_volante(int val_pot);
}

marco_c

I am having trouble understanding the question, so I will give a few answers and hopefully one will answer the question.

Once the code is compiled, the 'library' is part of the binary data downloaded to the processor and is no longer a separate thing. It becomes part of the executable file.

For compiling you need to have the library installed either in Sketchbook/libraries folder or in the same folder as your sketch. It does not automatically install if someone else is using your library.

If you are including a third library in your own library, it works just like compiling the sketch - the library must be installed and it also become part of the binary code downloaded to the processor.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

jimLee

#2
Sep 19, 2019, 05:03 am Last Edit: Sep 19, 2019, 05:06 am by jimLee
"installing" a new  library is as simple as loading a folder with your .h & .cpp files (Of the library) and dragging that folder into your "libraries" folder. Then you can add it to your code as usual with #include "blabla.h" where needed.

Remember, your using libraries all the time and you probably don't realize it. Do you worry about them being "guaranteed that the library is going together?" No! And yours will be no different.

No worries!

-jim lee
PNW Ardiuno & Maker club
1012 9Th Street, Anacortes, WA 98221 (Around the back of building)

Go Up