13-07-2019, 01:27 PM
(Última modificación: 13-07-2019, 01:32 PM por sofia.aleman.
Razón: Ayuda
)
Hola, disculpen tengo un problema sale error al copilar
aqui les dejo la programación:
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include "DHT.h"
#define DHTPIN 2
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);// nombre de lcd
Servo servoMotorr;
const int LDRPin = A0;
const int umbral = 100;
/*-----( Declare Constants )-----*/
const int receiver = 3; // pin 1 of IR receiver to Arduino digital pin 11
const int Red = 9;// leds
const int Green = 10;// leds
const int Blue = 11;// leds
#define BUZZER 8
const float sonido = 34300.0; // Velocidad del sonido en cm/s
const float umbral1 = 30.0;
const float umbral2 = 20.0;
const float umbral3 = 10.0;
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
/*-----( Declare Variables )-----*/
void setup(){ /*----( SETUP: RUNS ONCE )----*/
Serial.begin(9600);
Serial.println("IR Receiver Raw Data + Button Decode Test");
Serial.print(9600);
irrecv.enableIRIn(); // Start the receiver
lcd.begin();
lcd.clear();
dht.begin();
pinMode(BUZZER, OUTPUT);
pinMode (Red, OUTPUT);
pinMode (Green, OUTPUT);
pinMode (Blue, OUTPUT);
pinMode(LDRPin, INPUT);
servoMotorr.write(0); // Inicializamos al ángulo 0 el servomotor
servoMotorr.attach(4);// pin del servo
}/*--(end setup )---*/
void EstablecerColor(int R, int G, int B) {
analogWrite(Red, R);
analogWrite(Green, G);
analogWrite(Blue, B);
}
void loop(){
lcd.clear();
lcd.backlight();
lcd.setCursor(0, 0);// linea 1 del lcd
float t = dht.readTemperature();
if ( t == 25) {//cuando es temperatura ambiente
lcd.setCursor(0, 1);
lcd.print("temperatura normal");
}
if ( t > 27) {
EstablecerColor (255, 255, 0);
tone(BUZZER, 3000, 200);
}
if ( t > 29) {
EstablecerColor (255, 0, 0);
tone(BUZZER, 2500, 200);
}
int input = analogRead(LDRPin);
{
if (input > umbral) {
digitalWrite(Red, LOW);
tone(BUZZER, 2500, 200);
}
else {
digitalWrite(Green, HIGH);
}
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
// Serial.println(results.value, HEX); UN Comment to see raw values
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */
}
}
/*-----( Declare User-written Functions )-----*/
void translateIR() // takes action based on IR code received
// describing Car MP3 IR codes
{
switch (results.value)
{
case 0xFF6897:
Serial.println(" 0 ");
lcd.setCursor(0, 0);// linea 2 del lcd
lcd.print("0");
EstablecerColor(0, 255, 0);
servoMotorr.write(0);
break;
case 0xFF30CF:
Serial.println(" 1 ");
lcd.setCursor(0, 0);// linea 2 del lcd
servoMotorr.write(45);
lcd.print("45");
EstablecerColor(255, 0, 0);
break;
case 0xFF18E7:
Serial.println(" 2 ");
lcd.setCursor(0, 0);// linea 2 del lcd
servoMotorr.write(90);
lcd.print("90");
EstablecerColor(0, 255, 0);
break;
case 0xFF7A85:
Serial.println(" 3 ");
lcd.setCursor(0, 0);// linea 2 del lcd
lcd.print("120");
EstablecerColor(255, 255, 0);
servoMotorr.write(120);
break;
case 0xFF10EF:
Serial.println(" 4 ");
lcd.setCursor(0, 0);// linea 2 del lcd
lcd.print("180");
EstablecerColor(0, 255, 255);
servoMotorr.write(180);
break;
default:
Serial.println(" other button ");
EstablecerColor (0, 0, 0);
}
delay(500);
}
aqui les dejo la programación:
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include "DHT.h"
#define DHTPIN 2
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);// nombre de lcd
Servo servoMotorr;
const int LDRPin = A0;
const int umbral = 100;
/*-----( Declare Constants )-----*/
const int receiver = 3; // pin 1 of IR receiver to Arduino digital pin 11
const int Red = 9;// leds
const int Green = 10;// leds
const int Blue = 11;// leds
#define BUZZER 8
const float sonido = 34300.0; // Velocidad del sonido en cm/s
const float umbral1 = 30.0;
const float umbral2 = 20.0;
const float umbral3 = 10.0;
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
/*-----( Declare Variables )-----*/
void setup(){ /*----( SETUP: RUNS ONCE )----*/
Serial.begin(9600);
Serial.println("IR Receiver Raw Data + Button Decode Test");
Serial.print(9600);
irrecv.enableIRIn(); // Start the receiver
lcd.begin();
lcd.clear();
dht.begin();
pinMode(BUZZER, OUTPUT);
pinMode (Red, OUTPUT);
pinMode (Green, OUTPUT);
pinMode (Blue, OUTPUT);
pinMode(LDRPin, INPUT);
servoMotorr.write(0); // Inicializamos al ángulo 0 el servomotor
servoMotorr.attach(4);// pin del servo
}/*--(end setup )---*/
void EstablecerColor(int R, int G, int B) {
analogWrite(Red, R);
analogWrite(Green, G);
analogWrite(Blue, B);
}
void loop(){
lcd.clear();
lcd.backlight();
lcd.setCursor(0, 0);// linea 1 del lcd
float t = dht.readTemperature();
if ( t == 25) {//cuando es temperatura ambiente
lcd.setCursor(0, 1);
lcd.print("temperatura normal");
}
if ( t > 27) {
EstablecerColor (255, 255, 0);
tone(BUZZER, 3000, 200);
}
if ( t > 29) {
EstablecerColor (255, 0, 0);
tone(BUZZER, 2500, 200);
}
int input = analogRead(LDRPin);
{
if (input > umbral) {
digitalWrite(Red, LOW);
tone(BUZZER, 2500, 200);
}
else {
digitalWrite(Green, HIGH);
}
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
// Serial.println(results.value, HEX); UN Comment to see raw values
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */
}
}
/*-----( Declare User-written Functions )-----*/
void translateIR() // takes action based on IR code received
// describing Car MP3 IR codes
{
switch (results.value)
{
case 0xFF6897:
Serial.println(" 0 ");
lcd.setCursor(0, 0);// linea 2 del lcd
lcd.print("0");
EstablecerColor(0, 255, 0);
servoMotorr.write(0);
break;
case 0xFF30CF:
Serial.println(" 1 ");
lcd.setCursor(0, 0);// linea 2 del lcd
servoMotorr.write(45);
lcd.print("45");
EstablecerColor(255, 0, 0);
break;
case 0xFF18E7:
Serial.println(" 2 ");
lcd.setCursor(0, 0);// linea 2 del lcd
servoMotorr.write(90);
lcd.print("90");
EstablecerColor(0, 255, 0);
break;
case 0xFF7A85:
Serial.println(" 3 ");
lcd.setCursor(0, 0);// linea 2 del lcd
lcd.print("120");
EstablecerColor(255, 255, 0);
servoMotorr.write(120);
break;
case 0xFF10EF:
Serial.println(" 4 ");
lcd.setCursor(0, 0);// linea 2 del lcd
lcd.print("180");
EstablecerColor(0, 255, 255);
servoMotorr.write(180);
break;
default:
Serial.println(" other button ");
EstablecerColor (0, 0, 0);
}
delay(500);
}