##Project Pochito hola
Last active
June 8, 2021 22:37
-
-
Save ArielNicotena/eab262de1b884e2595f3654e69362e22 to your computer and use it in GitHub Desktop.
Scripts De Sensores - Arduino UNO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Acelerometro - GY-61 | |
Voltaje - 3,3V | |
*/ | |
const int xpin = A0; | |
const int ypin = A1; | |
const int zpin = A2; | |
void setup() { | |
Serial.begin(9300); | |
} | |
void loop() { | |
int x = analogRead(xpin); | |
delay(1); | |
int y = analogRead(ypin); | |
delay(1); | |
int z = analogRead(zpin); | |
delay(1); | |
Serial.print("X"); | |
Serial.print(x); | |
Serial.print("\t"); | |
Serial.print("Y"); | |
Serial.print(y); | |
Serial.print("\t"); | |
Serial.print("Z"); | |
Serial.print(z); | |
Serial.print("\n"); | |
delay (500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Actuador - Lumatech XTL && Sovik | |
Voltaje - 12V | |
*/ | |
int IN1 = 10; // IN1 de L298N a pin digital 2 | |
int IN2 = 11; // IN2 de L298N a pin digital 3 | |
int ENA = 12; // ENA de L298N a pin digital 5 | |
void setup(){ | |
pinMode(IN1, OUTPUT); // pin 2 como salida | |
pinMode(IN2, OUTPUT); // pin 3 como salida | |
pinMode(ENA, OUTPUT); // pin 5 como salida | |
} | |
void loop(){ | |
digitalWrite(ENA, HIGH); // habilita motor A (giro en un sentido) | |
digitalWrite(IN1, LOW); // IN1 a 0 | |
digitalWrite(IN2, HIGH); // IN2 a 1 | |
delay(3000); // demora de 3 seg. | |
digitalWrite(ENA, LOW); // ENA en 0 para deshabilitar motor | |
delay(2000); // demora de 2 seg. | |
digitalWrite(ENA, HIGH); // habilita motor A (giro en sentido contrario) | |
digitalWrite(IN1, HIGH); // IN1 a 1 | |
digitalWrite(IN2, LOW); // IN2 a 0 | |
delay(3000); // demora de 3 seg | |
digitalWrite(ENA, LOW); // ENA en 0 para deshabilitar motor | |
delay(2000); // demora de 2 seg. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define met A1 | |
#define ledod 3 | |
#define ledmo 4 | |
#define ledme 5 | |
#define ledac 6 | |
#define mpwr 8 | |
#define mdir 9 | |
const int xpin = A2; | |
const int ypin = A3; | |
const int zpin = A4; | |
int IN1 = 10; // IN1 de L298N a pin digital 2 | |
int IN2 = 11; // IN2 de L298N a pin digital 3 | |
int ENA = 12; // ENA de L298N a pin digital 5 | |
int ap = 0; | |
void setup(){ | |
Serial.begin(9600); | |
pinMode(IN1, OUTPUT); // pin 2 como salida | |
pinMode(IN2, OUTPUT); // pin 3 como salida | |
pinMode(ENA, OUTPUT); // pin 5 como salida | |
pinMode(met,INPUT_PULLUP); | |
pinMode(ledod,OUTPUT); | |
pinMode(ledmo,OUTPUT); | |
pinMode(ledme,OUTPUT); | |
pinMode(ledac,OUTPUT); | |
pinMode(mpwr,OUTPUT); | |
pinMode(mdir,OUTPUT); | |
} | |
void loop(){ | |
digitalWrite(ledod,LOW); | |
digitalWrite(ledmo,HIGH); | |
for (int i=0;i<30;i++) odo(); | |
digitalWrite(ledac,LOW); | |
digitalWrite(ledod,HIGH); | |
actuador(); | |
digitalWrite(ledme,LOW); | |
digitalWrite(ledac,HIGH); | |
for (int i=0;i<150;i++) metal(); | |
digitalWrite(ledmo,LOW); | |
digitalWrite(ledme,HIGH); | |
mot_i(); | |
mot_d(); | |
} | |
void actuador(){ | |
Serial.println("Esta funcionando Actuador"); | |
digitalWrite(ENA, HIGH); // habilita motor A (giro en un sentido) | |
digitalWrite(IN1, LOW); // IN1 a 0 | |
digitalWrite(IN2, HIGH); // IN2 a 1 | |
delay(1000); // demora de 3 seg. | |
digitalWrite(ENA, LOW); // ENA en 0 para deshabilitar motor | |
delay(500); // demora de 2 seg. | |
digitalWrite(ENA, HIGH); // habilita motor A (giro en sentido contrario) | |
digitalWrite(IN1, HIGH); // IN1 a 1 | |
digitalWrite(IN2, LOW); // IN2 a 0 | |
delay(1000); // demora de 3 seg | |
digitalWrite(ENA, LOW); // ENA en 0 para deshabilitar motor | |
delay(500); // demora de 2 seg. | |
} | |
void odo(){ | |
int sensorValue = analogRead(A0); | |
Serial.print("Esta funcionando Odometro : "); | |
Serial.println(sensorValue); | |
delay(100); | |
} | |
void metal(){ | |
ap = analogRead(met); | |
Serial.print("Esta funcionando Detector de Metal : "); | |
Serial.println(ap); | |
delay(15); | |
} | |
void mot_i(){ | |
Serial.println("Esta funcionando Motor"); | |
analogWrite(mpwr,255); | |
digitalWrite(mdir,HIGH); | |
delay(1000); | |
analogWrite(mpwr,0); | |
} | |
void mot_d(){ | |
Serial.println("Esta funcionando Motor"); | |
analogWrite(mpwr,255); | |
digitalWrite(mdir,LOW); | |
delay(1000); | |
analogWrite(mpwr,0); | |
} | |
/*void acelerometro(){ | |
int x = analogRead(xpin); | |
delay(1); | |
int y = analogRead(ypin); | |
delay(1); | |
int z = analogRead(zpin); | |
delay(1); | |
Serial.print("X"); | |
Serial.print(x); | |
Serial.print("\t"); | |
Serial.print("Y"); | |
Serial.print(y); | |
Serial.print("\t"); | |
Serial.print("Z"); | |
Serial.print(z); | |
Serial.print("\n"); | |
delay (500); | |
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Det Met - LJ18A3-8-Z/EX && LJ18A3-8-Z/BX | |
Voltaje - 5V | |
*/ | |
#define met A0 | |
#define led 7 | |
int ap = 0; | |
void setup() { | |
Serial.begin(9300); | |
pinMode(met,INPUT_PULLUP); | |
pinMode(led,OUTPUT); | |
} | |
void loop() { | |
ap = analogRead(met); | |
Serial.println(ap); | |
if (ap > 520){ | |
digitalWrite(led,LOW); | |
} | |
else { | |
digitalWrite(led,HIGH); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
GPS - GPS6MV2 | |
Voltaje - 5V | |
*/ | |
#include <SoftwareSerial.h> | |
#include <TinyGPS.h> | |
TinyGPS gps; | |
SoftwareSerial softSerial(4, 3); | |
void setup() | |
{ | |
Serial.begin(115200); | |
softSerial.begin(9600); | |
} | |
void loop() | |
{ | |
bool newData = false; | |
unsigned long chars; | |
unsigned short sentences, failed; | |
// Intentar recibir secuencia durante un segundo | |
for (unsigned long start = millis(); millis() - start < 1000;) | |
{ | |
while (softSerial.available()) | |
{ | |
char c = softSerial.read(); | |
if (gps.encode(c)) // Nueva secuencia recibida | |
newData = true; | |
} | |
} | |
if (newData) | |
{ | |
float flat, flon; | |
unsigned long age; | |
gps.f_get_position(&flat, &flon, &age); | |
Serial.print("LAT="); | |
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6); | |
Serial.print(" LON="); | |
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6); | |
Serial.print(" SAT="); | |
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites()); | |
Serial.print(" PREC="); | |
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop()); | |
} | |
gps.stats(&chars, &sentences, &failed); | |
Serial.print(" CHARS="); | |
Serial.print(chars); | |
Serial.print(" SENTENCES="); | |
Serial.print(sentences); | |
Serial.print(" CSUM ERR="); | |
Serial.println(failed); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Motor de Direccion - | |
Voltaje - 12V | |
*/ | |
#define mpwr 8 | |
#define mdir 9 | |
void setup() { | |
Serial.begin(9300); | |
pinMode(mpwr,OUTPUT); | |
pinMode(mdir,OUTPUT); | |
} | |
void loop() { | |
analogWrite(mpwr,255); | |
digitalWrite(mdir,LOW); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Pantalla - 0.96 Oled | |
Voltaje - 5V | |
*/ | |
#include <SPI.h> | |
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#define SCREEN_WIDTH 128 // Ancho de la pantalla | |
#define SCREEN_HEIGHT 64 // Altura de la pantalla | |
// Declaración de los pines de la pantalla OLED | |
#define OLED_MOSI 3 | |
#define OLED_CLK 2 | |
#define OLED_DC 5 | |
#define OLED_CS 6 | |
#define OLED_RESET 4 | |
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, | |
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); | |
#define LOGO_HEIGHT 64 //Alto de la imagen a mostrar | |
#define LOGO_WIDTH 128 //Ancho de la imagen a mostrar | |
//Imagen generada en "http://javl.github.io/image2cpp/" | |
static const unsigned char PROGMEM logo_bmp[] = | |
{ | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x60, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x90, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0xff, 0xf8, 0xf4, 0x00, 0x00, 0x20, 0x00, 0x00, 0x70, | |
0x3f, 0xff, 0x80, 0x70, 0x03, 0xfc, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xe0, 0xff, 0xf8, 0xf0, 0xf8, | |
0x7f, 0xff, 0xc0, 0xf8, 0x07, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xf9, 0xf8, | |
0x7f, 0xff, 0xc1, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xf9, 0xf8, | |
0x3f, 0xff, 0xc3, 0xfc, 0x1f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xfb, 0xff, 0xf0, | |
0x1f, 0xff, 0x83, 0xfc, 0x3f, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xf3, 0xff, 0xe0, | |
0x00, 0xff, 0x03, 0xfe, 0x3f, 0xfd, 0xfe, 0x00, 0x7f, 0xe1, 0xfc, 0x7c, 0xfe, 0x01, 0xff, 0xc0, | |
0x01, 0xfe, 0x07, 0xfe, 0x7f, 0xfc, 0xff, 0xf8, 0x1f, 0xe1, 0xfe, 0x7c, 0xff, 0xf1, 0xff, 0xc0, | |
0x03, 0xfe, 0x07, 0xfe, 0x7f, 0x27, 0xff, 0xf8, 0x1f, 0xe1, 0xff, 0xfc, 0xff, 0xf8, 0xff, 0xc0, | |
0x03, 0xfc, 0x07, 0xff, 0x7f, 0x33, 0xff, 0xfc, 0x1f, 0xe1, 0xff, 0xfc, 0xff, 0xf8, 0x7f, 0xe0, | |
0x07, 0xf8, 0x0f, 0xff, 0x7f, 0x99, 0xff, 0xf8, 0x1f, 0xe1, 0xff, 0xf8, 0xff, 0xf8, 0x7f, 0xf0, | |
0x0f, 0xf8, 0x0f, 0xff, 0xff, 0xcf, 0xff, 0xf8, 0x1f, 0xe1, 0xff, 0xf0, 0xff, 0xf0, 0x3f, 0xf0, | |
0x1f, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0x80, 0x1f, 0xe1, 0xff, 0xf0, 0xfe, 0x00, 0x3f, 0xf8, | |
0x1f, 0xe0, 0x1f, 0xff, 0xbf, 0xff, 0xff, 0xf0, 0x1f, 0xe1, 0xfd, 0xf8, 0xfe, 0x00, 0x7f, 0xfc, | |
0x3f, 0xff, 0x9f, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x1f, 0xf1, 0xfc, 0xfc, 0xff, 0xf8, 0xff, 0xfc, | |
0x7f, 0xff, 0xff, 0x1f, 0xdf, 0xff, 0xff, 0xfc, 0x1f, 0xf1, 0xfc, 0x7c, 0xff, 0xfc, 0xfd, 0xfe, | |
0x7f, 0xff, 0xfe, 0x1f, 0xcf, 0xff, 0xff, 0xfc, 0x1f, 0xf1, 0xfc, 0x7e, 0xff, 0xfd, 0xf9, 0xfe, | |
0x7f, 0xff, 0xfe, 0x1f, 0xe7, 0xfe, 0xff, 0xfc, 0x0f, 0xf1, 0xfe, 0x3e, 0xff, 0xf9, 0xf0, 0xf8, | |
0x3b, 0xff, 0x9c, 0x0e, 0xc1, 0xfc, 0x7f, 0xfc, 0x0f, 0xe3, 0xff, 0x1c, 0x7f, 0xf0, 0xe0, 0x70, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x03, 0xf0, 0x00, 0x01, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x18, 0x08, 0x00, 0x00, 0x0c, 0x81, 0xbf, 0xc0, 0x07, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x18, 0x0f, 0xfb, 0xfb, 0x8f, 0xe3, 0xff, 0xee, 0x0f, 0xf9, 0xfc, 0xef, 0xf7, 0xf0, 0x00, | |
0x00, 0x01, 0x45, 0xfc, 0xe6, 0x8b, 0x9a, 0xe7, 0xbb, 0x0b, 0xea, 0x7a, 0xab, 0xf9, 0xc8, 0x00, | |
0x00, 0x01, 0x45, 0xe5, 0xbe, 0xfa, 0x8e, 0xef, 0x9b, 0x0b, 0x6a, 0xfe, 0xab, 0xcb, 0xf0, 0x00, | |
0x00, 0x01, 0x45, 0x65, 0x1a, 0x03, 0xb2, 0xef, 0x9b, 0x1b, 0x2a, 0xe2, 0xa8, 0xc4, 0x08, 0x00, | |
0x00, 0x01, 0x45, 0xf5, 0xf6, 0xfa, 0xbc, 0xef, 0x9b, 0xfb, 0xea, 0xfa, 0xab, 0xef, 0xe8, 0x00, | |
0x00, 0x01, 0x44, 0x0c, 0x0a, 0x8a, 0xb6, 0xe0, 0x38, 0x18, 0x0a, 0x02, 0xa8, 0x18, 0x18, 0x00, | |
0x00, 0x01, 0x87, 0xfb, 0xf9, 0x86, 0x67, 0x9f, 0xff, 0xf7, 0xf1, 0xfc, 0xcf, 0xf7, 0xf0, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x80, 0xff, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x06, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x90, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
void setup() { | |
Serial.begin(9600); | |
// Inializando el OLED | |
if(!display.begin(SSD1306_SWITCHCAPVCC)) { | |
Serial.println(F("el modulo fallo")); | |
for(;;); //No hace nada, bucle permanente | |
} | |
} | |
void loop() { | |
/*testdrawbitmap(logo_bmp,128, 64); // Muestra imagen | |
// Invierte los colores | |
display.invertDisplay(true); | |
delay(2000); | |
display.invertDisplay(false); | |
delay(2000);*/ | |
testdrawstyles("HELLO WORLD"); // Muestra texto | |
delay(2000); | |
} | |
void testdrawstyles(String texto) { | |
display.clearDisplay(); // Limpia la pantalla | |
display.setTextSize(1); // Tamaño del texto | |
display.setTextColor(WHITE); // Color del texto | |
display.setCursor(0,32); // Coordenadas de inicio del texto | |
display.println(texto); | |
display.display(); // Muestra el texto con las configuraciones dadas | |
} | |
void testdrawbitmap(const uint8_t *imagen, int16_t ancho, int16_t alto) { | |
display.clearDisplay(); // Limpia la pantalla | |
display.drawBitmap( // Dibuja Imagen | |
(display.width() - ancho ) / 2, | |
(display.height() - alto) / 2, | |
imagen, ancho, alto, 1); | |
display.display(); // Muestra el texto con las configuraciones dadas | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Relay - 8 Puertos | |
Voltaje - 5V | |
*/ | |
int relay = 2; | |
void setup() { | |
pinMode(relay, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
digitalWrite(relay, HIGH); | |
Serial.println("Relay accionado"); | |
delay(1000); | |
digitalWrite(relay, LOW); | |
Serial.println("Relay no accionado"); | |
delay(1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ledA 7 | |
const byte pinObstaculo = 8; | |
int hayObstaculo = HIGH; | |
int val = 0; | |
void setup() { | |
Serial.begin(9300); | |
pinMode(ledA , OUTPUT); | |
} | |
void loop() { | |
hayObstaculo = digitalRead(pinObstaculo); | |
if (hayObstaculo == LOW){ | |
Serial.println("Obstaculo Detectado!!"); | |
digitalWrite(ledA, HIGH); | |
} | |
else{ | |
Serial.println("Despejado"); | |
digitalWrite(ledA, LOW); | |
} | |
delay(20); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sensor - H2010 | |
Voltaje - 5V | |
*/ | |
void setup(){ | |
Serial.begin(9600); | |
} | |
void loop(){ | |
int sensorValue = analogRead(A0); | |
Serial.println(sensorValue); | |
delay(100); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Buenisimo