#include "DHT.h"
#define DHTPIN 7
#define DHTTYPE DHT22
#include "LedControlMS.h"
#include "pitches.h"
#include <Servo.h>
#include <LiquidCrystal.h>
LedControl lc=LedControl(11,13,10,1);
DHT dht(DHTPIN, DHTTYPE);
Servo myservo;
const int numberOfImages = 10;
//Numbers 0 to 9 as images
byte images[numberOfImages][8]
{
{
0b00000000,
0b00100100,
0b01111110,
0b00100100,
0b00000000,
0b01000010,
0b00100100,
0b00011000
},{
B00000000,
B00111100,
B01100110,
B00000110,
B00001100,
B00110000,
B01100000,
B01111110
},{
B00000000,
B00111100,
B01100110,
B00000110,
B00011100,
B00000110,
B01100110,
B00111100
},{
B00000000,
B00001100,
B00011100,
B00101100,
B01001100,
B01111110,
B00001100,
B00001100
},{
B00000000,
B01111110,
B01100000,
B01111100,
B00000110,
B00000110,
B01100110,
B00111100
},{
B00000000,
B00111100,
B01100110,
B01100000,
B01111100,
B01100110,
B01100110,
B00111100
},{
B00000000,
B01111110,
B01100110,
B00001100,
B00001100,
B00011000,
B00011000,
B00011000
},{
B00000000,
B00111100,
B01100110,
B01100110,
B00111100,
B01100110,
B01100110,
B00111100
},{
B00000000,
B00111100,
B01100110,
B01100110,
B00111110,
B00000110,
B01100110,
B00111100
},{
B00000000,
B00111100,
B01100110,
B01101110,
B01110110,
B01100110,
B01100110,
B00111100
}};
//The pins assigned to the different attached inputs and outputs
int pos = 0;
const int btn1Pin = 2;
const int btn2Pin = 3;
const int btn3Pin = 4;
const int led1Pin = A0;
const int led2Pin = A1;
const int led3Pin = A2;
const int trigPin = 5; // Trigger
const int echoPin = 6; // Echo
//Variable to store the ping time and distance
long duration, cm;
//Number of notes in the melody
const int numberOfNotes = 8;
//8 notes to play when playMelody() is run
const int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};
//Duration of each of the 8 notes
const int noteDurations[] = {
4, 8, 8, 4, 4, 4, 4, 4
};
#include "simpleFunctions.h"
void setup(){
//start serial connection
Serial.begin(9600);
Serial.println("Setting up...");
//Buttons and LEDs - input pullup means that resistors are not needed on buttons
pinMode(btn1Pin, INPUT_PULLUP);
pinMode(btn2Pin, INPUT_PULLUP);
pinMode(btn3Pin, INPUT_PULLUP);
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
pinMode(led3Pin, OUTPUT);
//Distance Sensor
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
//Temperature Sensor
dht.begin();
//Test
//Add your code here that will only run ONCE on startup
Serial.println("Setup Complete. Moving to loop");
}
void loop()
{
int currentDistance = readDistance();
int currentTemp = readHeat();
int currentHum = readHum();
int button1 = digitalRead(btn1Pin);
int button2 = digitalRead(btn2Pin);
int button3 = digitalRead(btn3Pin);
Serial.println("Looping...");
//Add your code here that will continually repeat
delay(300);
}