proyectos renombrados, reestructuracion

pendientes crear, indexar y linkear readmes
This commit is contained in:
jp.av.dev 2022-04-04 01:11:04 -04:00
parent 117e066867
commit 85bf8bb429
102 changed files with 562 additions and 26 deletions

0
EEPROM/README.md Normal file
View File

View File

@ -1,16 +1,16 @@
# Apuntes arduino
### Apuntes de implementación de librerias utilizadas frecuentemente.
### Apuntes de implementación de librerias de uso frecuente.
Son fragmentos de proyectos que usan objetos y metodos de librerias.
Fragmentos de proyectos que usan instancias, metodos y funciones de librerias
de uso frecuente en proyectos con Arduino.
El fin de este respositorio es encontrar una guia rápida de como implementar
alguna solución a una futura necesidad, sin necesidad de volver a navegar
entre videos, guias, documentación nuevamente.
Esta repo es el producto de la actividad antes mencionada.
alguna solución a una futura necesidad.
Implementaciones :
- Buzzers/Parlantes
- [Buzzers/Speakers](./buzzer/README.md)
- [BlueTooth](./BlueTooth/README.md)
- Serial Com
- EEPROM
@ -19,6 +19,6 @@ Implementaciones :
- Leds
- Distintos tipos de motores
- PWM
- RTC
- [Real Time Clock](./RTC/README.md)
- Sensores
- otros Tests

497
RTC/README.md Normal file
View File

@ -0,0 +1,497 @@
# RTC
## Real Time Clock
DS3231
- [Ejm Básico](#funciones-para-hora-y-fecha)
- [Ajuste Hora y Fecha](#ajuste-hora-y-fecha)
- [Ajuste Hora y Fecha según tiempo de compilación](#set-hora-y-fecha-segun-datos-de-compilacion)
- [Conexiones](#conexiones)
- [RTC LCD y Bluetooth](#rtc-lcd-y-bluetooth)
### Funciones para hora y fecha
**RTC DS3231** conectado por **I2C** y libreria **Wire**
```c
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {
"Domingo", "Lunes", "Martes",
"Miercoles", "Jueves", "Viernes",
"Sabado"};
void setup () {
#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif
Serial.begin(9600);
delay(3000); // wait for console opening
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}
void loop () {
DateTime now = rtc.now();
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(" ");
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" desde medianoche del 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
/*
// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));
Serial.print(" hoy +7d +30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
*/
Serial.println();
delay(3000);
}
```
----
### Ajuste Hora y Fecha
Usando un RX8025 RTC conectado via I2C y libreria Wire
```c
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 RTC; //Create the DS3231 object
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
//year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6)
//writing any non-existent time-data may interfere with normal operation of the RTC.
//Take care of week-day also.
DateTime dt(2018, 3, 20, 21, 51, 0);
void setup(){
Serial.begin(57600);
Wire.begin();
RTC.begin();
RTC.adjust(dt); //Adjust date-time as defined 'dt' above
}
void loop(){
DateTime now = RTC.now(); //get the current date-time
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
//Serial.print(now.date(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
//Serial.print(weekDay[now.dayOfWeek()]);
Serial.println();
delay(1000);
}
```
### Set hora y fecha segun datos de compilacion
```c
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
// Pines del chip I2C al LCD:
// (addr,en,rw,rs,d4,d5,d6,d7,BackLight, BLstatus)
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address [0x27 o 0x3F]
RTC_DS3231 reloj;
bool alarma = true;
DateTime fecha;
void setup() {
Serial.begin(9600);
lcd.begin(20,4);
if(!reloj.begin()) {
Serial.println("Modulo RTC no encontrado!!");
while(1); // 1 = true - blucle infito si no hay modulo
}
//reloj.adjust(DateTime(__DATE__, __TIME__)); // Descomentar para ajustar fecha y hora
}
void loop() {
fecha = reloj.now();
getFecha();
lcd.clear();
lcd.home();
mostrarHora();
delay(1000);
}
void getFecha() {
Serial.print(fecha.day());
Serial.print("/");
Serial.print(fecha.month());
Serial.print("/");
Serial.print(fecha.year());
Serial.print(" ");
Serial.print(fecha.hour());
Serial.print(":");
Serial.print(fecha.minute());
Serial.print(":");
Serial.println(fecha.second());
}
String getHora(char var) {
switch (var) {
case 'h':
if(fecha.hour() < 10) {
return ('0'+(String)fecha.hour()); break;
} else {
return (String)fecha.hour();break;
}
case 'm':
if(fecha.minute() <10) {
return ('0'+(String)fecha.minute()); break;
} else {
return (String)fecha.minute();break;
}
case 's':
if(fecha.second() <10) {
return ('0'+(String)fecha.second()); break;
} else {
return (String)fecha.second();break;
}
}
}
void mostrarHora() {
lcd.print("La hora es: ");
lcd.print(getHora('h'));
lcd.print(":");
lcd.print(getHora('m'));
lcd.print(":");
lcd.print(getHora('s'));
lcd.setCursor(0, 1);
}
```
### Set hora y fecha segun datos de compilacion
`reloj.adjust(DateTime(__DATE__, __TIME__));`
```c
#include <RTClib.h>
RTC_DS3231 reloj;
bool alarma = true;
DateTime fecha;
void setup(){
Serial.begin(9600);
if(!reloj.begin()){
Serial.println("Modulo RTC no encontrado!!");
while(1); // 1 = true - blucle infito si no hay modulo
}
// Ajustes fecha y hora según tiempo de compilación
reloj.adjust(DateTime(__DATE__, __TIME__));
}
void loop() {
fecha = reloj.now();
getFecha();
delay(1000);
}
/*
if(fecha.hour() == 13 && fecha.minute() == 00) {
if(alarma == true) {
Serial.println("Alarma 1 PM");
alarma = false;
}
}
getFecha();
delay(1000);
if(fecha.hour() == 12 && fecha.minute() ==30) {
alarma = true;
}
}
*/
void getFecha() {
Serial.print(fecha.day());
Serial.print("/");
Serial.print(fecha.month());
Serial.print("/");
Serial.print(fecha.year());
Serial.print(" ");
Serial.print(fecha.hour());
Serial.print(":");
Serial.print(fecha.minute());
Serial.print(":");
Serial.println(fecha.second());
}
String getHora(char var) {
switch (var) {
case 'h':
if(fecha.hour() < 10) {
return ('0'+(String)fecha.hour()); break;
} else {
return (String)fecha.hour();break;
}
case 'm':
if(fecha.minute() <10) {
return ('0'+(String)fecha.minute()); break;
} else {
return (String)fecha.minute();break;
}
case 's':
if(fecha.second() <10) {
return ('0'+(String)fecha.second()); break;
} else {
return (String)fecha.second();break;
}
}
}
```
----
## RTC LCD y Bluetooth
### Conexiones
|HC - 06|ARDUINO|
|-|-|
|**`VCC`** | **`5V`**|
|**`GND`** | **`GND`**|
|**`TXD`** | **`10`**|
|**`RXD`** | **`11`**|
> Pines del chip I2C al LCD:
> (addr,en,rw,rs,d4,d5,d6,d7,BackLight, BLstatus)
```c
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
#define relLuz 13
#define relVent 12
#define sHum1 A0
#define sHum2 A1
#define sHum3 A2
#define sHum4 A3
byte hum1, hum2, hum3;
// (addr,en,rw,rs,d4,d5,d6,d7,BackLight, BLstatus)
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address [0x27 o 0x3F]
RTC_DS3231 reloj;
bool alarma = true;
DateTime fecha;
void setup() {
Serial.begin(9600);
lcd.begin(20,4);
if(!reloj.begin()) {
Serial.println("Modulo RTC no encontrado!!");
while(1); // 1 = true - blucle infito si no hay modulo
}
//reloj.adjust(DateTime(__DATE__, __TIME__)); // Descomentar para ajustar fecha y hora
}
void loop() {
lcd.clear();
lcd.home();
fecha = reloj.now();
mostrarFechaSerie();
horaLCD();
delay(1000);
}
//En caso de ser necesario mostrar hora, este codigo añade un 0 a los valores menores a 10
String getHora(char var) {
switch (var) {
case 'h':
if(fecha.hour() < 10) {
return ('0'+(String)fecha.hour()); break;
} else {
return (String)fecha.hour();break;
}
case 'm':
if(fecha.minute() <10) {
return ('0'+(String)fecha.minute()); break;
} else {
return (String)fecha.minute();break;
}
case 's':
if(fecha.second() <10) {
return ('0'+(String)fecha.second()); break;
} else {
return (String)fecha.second();break;
}
}
}
//Hora en LCD
void horaLCD() {
lcd.print("La hora es: ");
lcd.print(getHora('h'));
lcd.print(":");
lcd.print(getHora('m'));
lcd.print(":");
lcd.print(getHora('s'));
}
// Enviar hora y fecha por puerto serie
void mostrarFechaSerie() {
Serial.print(fecha.day());
Serial.print("/");
Serial.print(fecha.month());
Serial.print("/");
Serial.print(fecha.year());
Serial.print(" ");
Serial.print(getHora('h'));
Serial.print(":");
Serial.print(getHora('m'));
Serial.print(":");
Serial.println(getHora('s'));
}
```
----
```c
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
SoftwareSerial miBT(10,11);
// Pines del chip I2C al LCD:
// (addr,en,rw,rs,d4,d5,d6,d7,BackLight, BLstatus)
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address [0x27 o 0x3F]
RTC_DS3231 reloj;
bool alarma = true;
DateTime fecha;
void setup() {
Serial.begin(9600);
lcd.begin(20,4);
miBT.begin(9600);
if(!reloj.begin()) {
Serial.println("Modulo RTC no encontrado!!");
while(1); // 1 = true - blucle infito si no hay modulo
}
//reloj.adjust(DateTime(__DATE__, __TIME__)); // Descomentar para ajustar fecha y hora
}
void loop(){
fecha = reloj.now();
getFecha();
lcd.clear();
lcd.home();
mostrarHora();
comBT();
delay(1000);
}
//En caso de ser necesario mostrar hora, este codigo añade un 0 a los valores menores a 10
String getHora(char var) {
switch (var) {
case 'h':
if(fecha.hour() < 10) {
return ('0'+(String)fecha.hour()); break;
} else {
return (String)fecha.hour(); break;
}
case 'm':
if(fecha.minute() <10) {
return ('0'+(String)fecha.minute()); break;
} else {
return (String)fecha.minute();break;
}
case 's':
if(fecha.second() <10) {
return ('0'+(String)fecha.second()); break;
} else {
return (String)fecha.second();break;
}
}
}
//Hora en LCD
void mostrarHora() {
lcd.print("La hora es: ");
lcd.print(getHora('h'));
lcd.print(":");
lcd.print(getHora('m'));
lcd.print(":");
lcd.print(getHora('s'));
}
// Enviar hora y fecha por puerto serie
void getFecha() {
Serial.print(fecha.day());
Serial.print("/");
Serial.print(fecha.month());
Serial.print("/");
Serial.print(fecha.year());
Serial.print(" ");
Serial.print(fecha.hour());
Serial.print(":");
Serial.print(fecha.minute());
Serial.print(":");
Serial.println(fecha.second());
}
void comBT() {
if(miBT.available()) {
lcd.setCursor(0, 1);
while(miBT.available() > 0) {
lcd.print((char)miBT.read()); //lee BT y envia a Arduino
}
delay(1000);
}
if(Serial.available()) {
while(Serial.available() > 0) {
miBT.write(Serial.read()); // lee Arduino y envia a BT
}
}
}
```

View File

@ -1,5 +1,4 @@
// Date and time functions using a RX8025 RTC connected via I2C and Wire lib
// Funciones de Hora y Fecha usando un RX8025 RTC conectado via I2C y libreria Wire
#include <Wire.h>
#include "RTClib.h"
@ -12,17 +11,14 @@ char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
//Take care of week-day also.
DateTime dt(2018, 3, 20, 21, 51, 0);
void setup ()
{
void setup (){
Serial.begin(57600);
Wire.begin();
RTC.begin();
RTC.adjust(dt); //Adjust date-time as defined 'dt' above
}
void loop ()
{
void loop (){
DateTime now = RTC.now(); //get the current date-time
Serial.print(now.year(), DEC);
Serial.print('/');

View File

@ -1,10 +1,7 @@
#include <RTClib.h>
RTC_DS3231 reloj;
bool alarma = true;
DateTime fecha;
void setup() {
@ -13,7 +10,8 @@ void setup() {
Serial.println("Modulo RTC no encontrado!!");
while(1); // 1 = true - blucle infito si no hay modulo
}
reloj.adjust(DateTime(__DATE__, __TIME__)); // Descomentar para ajustar fecha y hora
// Ajustes fecha y hora según tiempo de compilación
reloj.adjust(DateTime(__DATE__, __TIME__));
}
void loop() {

44
buzzer/README.md Normal file
View File

@ -0,0 +1,44 @@
## Parlantes, Buzzers
- [2 potenciometros y 2 parlantes](#2-pots-2-speakers)
- [ejm. Graduación](./graduacion/graduacion.ino)
- [ejm. midi-to-arduino](./midi_to_ino/midi_to_ino.ino)
- [ejm. Mario1](./mario1/mario1.ino)
- [ejm. Mario2](./mario2/mario2.ino)
- [ejm. Mario3](./mario3/mario3.ino)
- [ejm. Mario4](./mario4/mario4.ino)
- [ejm. himno](./himno/himno.ino)
## 2 pots 2 speakers
Control de tiempo y tono
```c
#define pot1 A0
#define pot2 A1
#define pot3 A2
#define pot4 A3
#define spkrL 2
#define spkrR 1
void setup() {
//pinMode(spkrL, OUTPUT);
//pinMode(spkrR, OUTPUT);
}
void loop() {
// tone(pin, frequency, duration)
int duracionL=map(analogRead(pot3), 0, 1023, 10, 1000);
int duracionR=map(analogRead(pot4), 0, 1023, 10, 1000);
int tonoL=map(analogRead(pot1),0, 1023, 60, 5000);
int tonoR=map(analogRead(pot2),0, 1023, 60, 5000);
tone(spkrL, tonoL, duracionL);
delay(duracionL);
tone(spkrR, tonoR, duracionR);
delay(duracionR);
delay(30);
}
```
[Descargar](./stereo_2pots_2spkr/stereo_2pots_2spkr.ino)

0
grblUpload/README.md Normal file
View File

View File

0
motores/dc/README.md Normal file
View File

1
motores/pap/README.md Normal file
View File

@ -0,0 +1 @@

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

0
motores/servo/README.md Normal file
View File

Some files were not shown because too many files have changed in this diff Show More