Special feature
Controlled by an Arduino UNO
Coded in Arduino.
Panagiotis A. Chatziangelakis 961617.
The special feature consists of an Arduino UNO, a 16X2 liquid crystal display and a DHT11 humidity and Temperature sensor. The application of zed feature is to enable the micro-mouse to do a useful task that would enable the user to add the line following function to work in unison with the aforementioned sensor. In a hypothetical situation that a user would like a basic heat and humidity map of their house they would be able by making a line pattern on the floor and the micro-mouse following said line logging the sensor readings and so having a rough idea of the two environmental condition mentioned above.
#include <LiquidCrystal.h>
#include <dht.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int greenPin = 2;
dht sensor;
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// read the buttons
int read_LCD_buttons()
// the buttons when read are centered at these values: 0, 146, 330, 506, 749
// we add approximately 50 to the values and check to see if we are close using the live output function.
if (adc_key_in > 1000) return btnNONE; // We make this the first option for efficiency since it will be the most likely result.
lcd.setCursor(10,1); // Here we appoint the coordinates where the message will be shown on the lcd.
if (adc_key_in < 60) {
lcd.print ("Right ");
}
else if (adc_key_in < 200) {
lcd.print ("Up ");
}
else if (adc_key_in < 400) {
lcd.print ("Down ");
}
else if (adc_key_in < 600) {
lcd.print ("Left ");
}
else if (adc_key_in < 800) {
lcd.print ("Select");
return btnNONE; // when all others fail, return this...
}
void setup()
lcd.begin(16,2); //16 x 2 character display
void loop()
{
delay(2000); //The DHT11 sensor seemed to work better and displaying continuous output on the display without interruption when asked to update with a 2 sec delay
sensor.read11(greenPin);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Humidity = ");
lcd.print(sensor.humidity);
lcd.setCursor(0,1);
lcd.print("Temperature = ");
lcd.print(sensor.temperature);
}
}
The unforeseen situation did not allow us to encompass the special effect on the micro-mouse to work together with the already used microcontroller to be able to create interrupts using the ldr sensors that enable the machine follow the line and so not been able to make the data logging part of the code that would allow the micro-mouse to fulfil this additional function mentioned work fully.