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.

  • The code written in Arduino language includes two libraries for the microcontroller to be able to function with the lcd and sensor.

#include <LiquidCrystal.h>

#include <dht.h>

  • We define the pins that the lcd is using to function

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

  • Here we define the pin 2 as an analogue input for the output of the DHT11 sensor.

int greenPin = 2;

dht sensor;

  • The aforementioned lcd has additional buttons that can be used for further function and so we define them. When a button is pushed the button is shown on the lcd.

// 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()



  • We need to do and analogue to digital conversion to define when a button is pushed the analogue values of the buttons are centered in specific values that may differ from device to device so by using a live output.

// 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()

  • Here we initiate the loop that will show the output of the sensor on the lcd.

lcd.begin(16,2); //16 x 2 character display

void loop()


  • Here we appoint the coordinates of the messages Humidity and Temperature followed by the output of the sensor for each case respectively.

{

  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.

I BUILT MY SITE FOR FREE USING