https://www.dropbox.com/s/kgjcs132jnqui7n/
jueves, 17 de mayo de 2018
lunes, 5 de junio de 2017
6.- EL TODO
Arduino UNO _ (LCD + SERVO)
#include <LiquidCrystal.h>
// Pines que funcionarán como salida (DISPLAY)
LiquidCrystal lcd(13,12,11,10,9,8);
// Función para temperatura
float centigrados() {
int dato = analogRead(A0);
float c=(500.0*dato)/1023;
return(c);
}
byte grado[8] =
{
0b00001100, // Los definimos como binarios 0bxxxxxxx
0b00010010,
0b00010010,
0b00001100,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
void setup()
{
Serial.begin(19200);
lcd.begin(16,2);
lcd.createChar(1, grado);
lcd.setCursor(0,0);
lcd.print("POS.= ");
lcd.setCursor(0,1);
lcd.print("Temp.=");
}
void loop()
{
float Centigrados = centigrados();
lcd.setCursor(7,1);
lcd.print(Centigrados);
lcd.write(1);
delay(100);
if (Serial.available()) {
setup();
char key = Serial.read();
lcd.setCursor(8,0);
lcd.print(key);
if(key == '1'){
lcd.setCursor(6,0);
lcd.print("IZQUIERDA");
}
if(key == '2'){
lcd.setCursor(6,0);
lcd.print("MEDIO");
}
if(key == '3'){
lcd.setCursor(6,0);
lcd.print("DERECHA");
}
}
}
// Pines que funcionarán como salida (DISPLAY)
LiquidCrystal lcd(13,12,11,10,9,8);
// Función para temperatura
float centigrados() {
int dato = analogRead(A0);
float c=(500.0*dato)/1023;
return(c);
}
byte grado[8] =
{
0b00001100, // Los definimos como binarios 0bxxxxxxx
0b00010010,
0b00010010,
0b00001100,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
void setup()
{
Serial.begin(19200);
lcd.begin(16,2);
lcd.createChar(1, grado);
lcd.setCursor(0,0);
lcd.print("POS.= ");
lcd.setCursor(0,1);
lcd.print("Temp.=");
}
void loop()
{
float Centigrados = centigrados();
lcd.setCursor(7,1);
lcd.print(Centigrados);
lcd.write(1);
delay(100);
if (Serial.available()) {
setup();
char key = Serial.read();
lcd.setCursor(8,0);
lcd.print(key);
if(key == '1'){
lcd.setCursor(6,0);
lcd.print("IZQUIERDA");
}
if(key == '2'){
lcd.setCursor(6,0);
lcd.print("MEDIO");
}
if(key == '3'){
lcd.setCursor(6,0);
lcd.print("DERECHA");
}
}
}
Arduino UNO _ (KEYPAD)
#include <Servo.h>
#include <Keypad.h>
Servo myservo;
int pos = 0;
// Número de renglones y columnas
const byte rows = 4;
const byte cols = 4;
// Pines que funcionarán como entrada (TECLADO 4X4)
byte rowPins[4] = {2, 3, 4, 5};
byte colPins[4] = {6, 7, 8, 9};
char keys[rows][cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
void setup()
{
myservo.attach(11);
Serial.begin(19200);
}
void loop()
{
//pos=pos+90;
char key = keypad.getKey();
if (key != NO_KEY){
Serial.print(key);
if(key == '1'){
myservo.write(pos=0);
delay(10);
}
if(key == '2'){
myservo.write(pos=90);
delay(10);
}
if(key == '3'){
myservo.write(pos=180);
delay(10);
}
}
}
Suscribirse a:
Entradas (Atom)