You are on page 1of 2

#include <LiquidCrystal.

h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int lectura=0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hola mundo");
Serial.begin(9600);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print("bienvenido");
}
//ALCOHOLIMETRO
#include <EEPROM.h>
const int analogSensor = 0;
const int ledCount = 10;
const int ledSave = 0;
const int pushButtonSave = 12;
const int pushButtonRead = 13;
int
int
int
int

ledPins[] = {2,3,4,5,6,7,8,9,10,11};
buttonSave = 0;
buttonRead = 0;
buttonCount = 0;

void setup() {
//Serial.begin(9600);
pinMode(ledSave, OUTPUT);
pinMode(pushButtonSave, INPUT);
pinMode(pushButtonRead, INPUT);
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void guardar(int value) {
int temp1 = EEPROM.read(0);
int temp2 = EEPROM.read(1);
EEPROM.write(0, value);
EEPROM.write(1, temp1);
EEPROM.write(2, temp2);
//Serial.println("guardado");
delay(2000);
}
void mostrar() {
while (true) {
buttonRead = digitalRead(pushButtonRead);
if (buttonRead == HIGH) {
if (buttonCount < 3) {

int dataReaded = EEPROM.read(buttonCount);


//Serial.print(buttonCount);
//Serial.print("\t");
//Serial.println(dataReaded);
for (int ledHigh = 0; ledHigh < ledCount; ledHigh++) {
if (ledHigh < dataReaded) {
digitalWrite(ledPins[ledHigh], HIGH);
} else {
digitalWrite(ledPins[ledHigh], LOW);
}
}
buttonCount++;
delay(500);
} else {
break;
}
}
}
buttonCount = 0;
delay(500);
}
void loop() {
int dataLevel = map(analogRead(analogSensor), 700, 900, 0, ledCount);
if (dataLevel < 0) {
dataLevel = 0;
}
if (dataLevel > 10) {
dataLevel = 10;
}
//Serial.println(dataLevel);
for (int ledHigh = 0; ledHigh < ledCount; ledHigh++) {
if (ledHigh < dataLevel) {
digitalWrite(ledPins[ledHigh], HIGH);
} else {
digitalWrite(ledPins[ledHigh], LOW);
}
}
buttonSave = digitalRead(pushButtonSave);
if (buttonSave == HIGH) {
digitalWrite(ledSave, HIGH);
guardar(dataLevel);
} else {
digitalWrite(ledSave, LOW);
}
buttonRead = digitalRead(pushButtonRead);
if (buttonRead == HIGH) {
mostrar();
}
}

You might also like