Entradas

Mostrando entradas de noviembre, 2017

Sistema de riego (un solo led)

int Valor;  int led = 13; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); } void loop(){  Serial.print("Humedad:");  Valor = analogRead(0);  Serial.print(Valor);  if (Valor > 300)     Serial.println("Seco, necesitas regar plantas");     digitalWrite(led, HIGH);  if (Valor < 700)      Serial.println("Humedo, No se necesita regar las plantas");      digitalWrite(led, LOW);  }

Lector #Bibliolabs

Clic aquí para descargar los archivos .ino   Pines usados:    --------------------------                Arduino                Uno    Señal       Pin    --------------------------    RST/Reset    6 (9)    SPI SS       7 (10)    SPI MOSI    11 / ICSP-4    SPI MISO    12 / ICSP-1    SPI SCK     13 / ICSP-3 */ //incluimos las dos lbrerías necesarias #include <SPI.h> #include <MFRC522.h> #include <SoftwareSerial.h> #include <DFPlayer_Mini_Mp3.h> #define RST_PIN         9          // Estos dos pines son configurables #define SS_PIN          10 int bvol = A5; // Volumen-- int bVOL = A4; // Volumen++ int bCapAnterior = A3; // Capitulo anterior int bPlayPause = A1; // Play/Pause int bCapSiguiente = A0; // Capitulo siguiente int volumen = 20; bool flag1 = false; bool state = true; MFRC522 mfrc522(SS_PIN, RST_PIN);  // Se crea una instancia MFRC522 //Se declara cada libro con su UID #define principito  0x3E4E3F4 #define veinteMilLegua

Sensor de humedad (alarma con led RGB)

Imagen
// Sensor de Humedad                       // Conectamos el sensor de la siguiente forma:             // GND    -> GND             // VCC    -> 5V             // DAT    -> A0                    int Valor;   int rojo = 6; int azul = 5; int verde = 3; void setup() { Serial.begin(9600); pinMode(rojo, OUTPUT); pinMode(azul, OUTPUT); pinMode(verde, OUTPUT); }  void loop(){   Serial.print("Humedad:");   Valor = analogRead(0);   Serial.print(Valor);   if (Valor <= 300)      Serial.println("Encharcado");      analogWrite(rojo, 0);      analogWrite(verde, 255);      analogWrite(azul, 0);  if ((Valor > 300) and (Valor <= 700))       Serial.println("Humedo, no regar plantas");        analogWrite(rojo, 255);       analogWrite(verde,255);       analogWrite(azul, 0);  if (Valor > 700)       Serial.println("Seco, necesitas regar plantas");       analogWrite(rojo, 255

Alarma sonora y visual (con ultrasonido, buzzer y led RGB)

Imagen
int cm = 0; int buzzer = 11; int rojo = 6; int azul = 5; int verde = 3; long readUltrasonicDistance(int pin) {   pinMode(pin, OUTPUT);  // Clear the trigger   digitalWrite(pin, LOW);   delayMicroseconds(2);   // Sets the pin on HIGH state for 10 micro seconds   digitalWrite(pin, HIGH);   delayMicroseconds(10);   digitalWrite(pin, LOW);   pinMode(pin, INPUT);   // Reads the pin, and returns the sound wave travel time in microseconds   return pulseIn(pin, HIGH); } void setup() {   pinMode(7, INPUT);   Serial.begin(9600);   pinMode (buzzer, OUTPUT);   pinMode(rojo, OUTPUT);   pinMode(azul, OUTPUT);   pinMode(verde, OUTPUT); } void loop() {   // measure the ping time in cm   cm = 0.01723 * readUltrasonicDistance(7);     if (cm < 70) {      analogWrite(buzzer,128); //emite sonido      delay(500); //espera medio segundo      digitalWrite(buzzer, LOW); //deja de emitir      delay(500);//espera medio segundo      analogWrite(rojo, 255);     

Alarma sonora (Buzzer con Ultrasonido)

Imagen
int cm = 0; int buzzer = 11; long readUltrasonicDistance(int pin) {   pinMode(pin, OUTPUT);  // Clear the trigger   digitalWrite(pin, LOW);   delayMicroseconds(2);   // Sets the pin on HIGH state for 10 micro seconds   digitalWrite(pin, HIGH);   delayMicroseconds(10);   digitalWrite(pin, LOW);   pinMode(pin, INPUT);   // Reads the pin, and returns the sound wave travel time in microseconds   return pulseIn(pin, HIGH); } void setup() {   pinMode(7, INPUT);   Serial.begin(9600);   pinMode (buzzer, OUTPUT); } void loop() {   // measure the ping time in cm   cm = 0.01723 * readUltrasonicDistance(7);     if (cm < 70) {   analogWrite(buzzer,128); //emite sonido      delay(500); //espera medio segundo      digitalWrite(buzzer, LOW); //deja de emitir      delay(500);//espera medio segundo } else {    digitalWrite(buzzer, LOW); }   }

Alarma visual (Led con ultrasonido)

Imagen
int cm = 0; int led = 13; long readUltrasonicDistance(int pin) {   pinMode(pin, OUTPUT);  // Clear the trigger   digitalWrite(pin, LOW);   delayMicroseconds(2);   // Sets the pin on HIGH state for 10 micro seconds   digitalWrite(pin, HIGH);   delayMicroseconds(10);   digitalWrite(pin, LOW);   pinMode(pin, INPUT);   // Reads the pin, and returns the sound wave travel time in microseconds   return pulseIn(pin, HIGH); } void setup() {   pinMode(7, INPUT);   pinMode (led, OUTPUT); } void loop() {   // measure the ping time in cm   cm = 0.01723 * readUltrasonicDistance(7);     if (cm < 70) {   digitalWrite(led, HIGH);   delay(1000);   digitalWrite(led, LOW);   delay(1000); } else {   digitalWrite(led, LOW); }   }