Computer Science Final Richard Barkley

by RBarkley22 in Circuits > Arduino

125 Views, 0 Favorites, 0 Comments

Computer Science Final Richard Barkley

Box 2.jpg

My computer science final is an Arduino LCD display for the door to the MakerSpace. The sign indicates if the room is open based on the light intensity of the room. The box is wedged between the bars of the window and runs off of a 9V battery or wall power. The sign lets students know whether the room is open, and allows them to see which teacher is present in the room.

Supplies and Prototype 1

prototype 1.jpg

First prototype.

Using Arduino Uno and LCD screen (2x20) with I2C module to display inputs and outputs.

Electronic Supplies

x1 Arduino Uno

x1 (2x20) or (4x20) LCD screed with I2C module.

x1 Breadboard

x1 Photoresistor

x2 Green LEDs

x2 Red LEDs

x2 5V Capacitors

x4 Low ohm resistors

Jumper Cables

9 Volt Battery

Arduino AC to 9v power adaptor

Physical Supplies

Screws

Nuts

Drill

Hot Glue

Cardboard (wood optional)

soldering iron (optional)

Arduino Wiring

box 5.jpg
box 3.jpg

The wiring to the Arduino can be either male and female connection or solder connection.

Male & Female

- easily interchangeable

- Weaker connection (Can disconnect)

Soldered connection

- Strong connection.

- Can replace the use of a breadboard.

- Permanent connection.

Circuit & Code

Circut.jpg
#include //Including necessary libraries to the function. #include // Set the LCD address to 0x27 for a 20 chars and 4 line display LiquidCrystal_I2C lcd(0x27, 20, 4); void setup() { // initialize the LCD lcd.init(); //initialize outputs pinMode(9, OUTPUT); //Red LED pinMode(10,OUTPUT); //Red LED pinMode(11, OUTPUT); //Green LED pinMode(12, OUTPUT); //Green LED Serial.begin(9600); // start serial monitor to get baseline light intensity. lcd.backlight(); // Turn on the blacklight and print a message. } void loop() { //defining local variable "sensorValue" as the value the photoresistor reads. int sensorValue = analogRead(A0); Serial.println(sensorValue); //Start serial monitor and read the photoresistor every 100 milliseconds //Check serial monitor and see value outputted with the lights on and off. //These on and off values will be the tolerances for the if statement. //for example if the lights are on and the sensor is reading 35 then 35 is the minimum value for the on screen. if (sensorValue > 35) { lcd.setCursor(3, 0); //Setting the start point for the LCD on the first space in the top row. lcd.print("O'Dea MakerSpace"); //Printing the string inside the quote on indicated line. lcd.setCursor(2,0); lcd.print("Status: open"); lcd.setCursor(1,0); lcd.print("Current Teacher:"); lcd.setCursor(0,0); lcd.print("Dr. White"); digitalWrite(11, HIGH); //Switching the green LEDs on to indicate room is open. digitalWrite(12, HIGH); digitalWrite(10, LOW); //Switching the red LEDs off. digitalWrite(9, LOW); delay(500); //Constant power intervals to the LEDS in half secong intervals. //This is done to allow the LCD screen to keep a constant display and not blink. } else { lcd.print("O'Dea MakerSpace"); //Printing the string inside the quote on indicated line. lcd.setCursor(2,0); lcd.print("Status: Closed"); lcd.setCursor(1,0); lcd.print("No Teacher Present"); lcd.setCursor(0,0); lcd.print("Roll Irish"); digitalWrite(9, HIGH); //Switching the red LEDs on to indicate room is closed. digitalWrite(10, HIGH); digitalWrite(11, LOW); //Switching the green LEDs off. digitalWrite(12, LOW); delay(500); } }

Downloads

Helpful Sources