• Home
  • 2017
  • 2016
  • 2015
  • 2014
  • 2013
  • 2012
  • 2011

PDI Studio 5

Design to make a difference

Feed on
Posts
comments

Code

Dec 4th, 2013 by helboj

/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)

* —————————————————————————-
* “THE BEER-WARE LICENSE” (Revision 42):
* <helboj@rpi.edu> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Janus Helbo
* —————————————————————————-
*/

#include <DHT22.h>
#include <LiquidCrystal.h>
#include <stdio.h>

// Data wire is plugged into port 6 on the Arduino
// Connect a 4.7K resistor between VCC and the data pin (strong pullup)
#define DHT22_PIN 6

int MoiPin = A3;
int LigPin = A1;

int SwitchPin = 8;
int ButtonPin = 9;

int LcdPowerPin = 10;
int LcdContrastPin = 7;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Setup a DHT22 instance
DHT22 myDHT22(DHT22_PIN);

int i=1;
int On=1;
float Tem;
float Hum;
float Lig;
float Moi;
float MaxTem=0;
float MinTem=0;
float MaxHum=0;
float MinHum=0;
float MaxLig=0;
float MinLig=0;
float MaxMoi=0;
float MinMoi=0;

void setup() {
// put your setup code here, to run once:
pinMode(LcdPowerPin, OUTPUT);
pinMode(LcdContrastPin, OUTPUT);
digitalWrite(LcdPowerPin, HIGH);
analogWrite(LcdPowerPin, 200);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(“EDU-Ponic system”);
lcd.setCursor(0, 1);
lcd.print(“Starting up !”);
delay(3000); // time to read
}

void loop() {

if(digitalRead(SwitchPin)==1 && On==1){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Edu-Ponic System”);
lcd.setCursor(3, 1);
lcd.print(“SLEEPING”);
delay(2000);
lcd.noDisplay();
digitalWrite(LcdPowerPin, LOW);
On=0;
}
else if(digitalRead(SwitchPin)==0 && On==0){
lcd.display();
digitalWrite(LcdPowerPin, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Edu-Ponic System”);
lcd.setCursor(7, 1);
lcd.print(“ON”);
delay(2000);
i=1; // try i=-2000 instead later
On=1;
}

if(digitalRead(ButtonPin)==1 && On==1){
MaxTem=0;
MinTem=0;
MaxHum=0;
MinHum=0;
MaxMoi=0;
MinMoi=0;
MaxLig=0;
MinLig=0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Edu-Ponic System”);
lcd.setCursor(5, 1);
lcd.print(“RESET”);
delay(2000);
}

switch (i) {
case 1:
DHT22_ERROR_t errorCode;
errorCode = myDHT22.readData();
if(errorCode==DHT_ERROR_NONE){
Tem = (myDHT22.getTemperatureC() * 9.00)/5.00 + 32.00;
Hum = myDHT22.getHumidity();
}
Moi = map(analogRead(MoiPin),0,650,0,110);
Lig = map(analogRead(LigPin),160,1023,0,110);

// Save values of max and min if we have new extremes
if(Tem>MaxTem || MaxTem==0){
MaxTem=Tem;
}
if(Tem<MinTem || MinTem==0){
MinTem=Tem;
}

if(Hum>MaxHum || MaxHum==0){
MaxHum=Hum;
}
if(Hum<MinHum || MinHum==0){
MinHum=Hum;
}

if(Moi>MaxMoi || MaxMoi==0){
MaxMoi=Moi;
}
if(Moi<MinMoi || MinMoi==0){
MinMoi=Moi;
}

if(Lig>MaxLig || MaxLig==0){
MaxLig=Lig;
}
if(Lig<MinLig || MinLig==0){
MinLig=Lig;
}

if(On==0){
i=0;
delay(1000*60);
}

break;
case 10:
Display(“Temperature”, “Now:”, Tem, “F”);
break;
case 20:
Display(“Temperature”, “Min:”, MinTem, “F”);
if(MinTem<32){
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Edu-Ponic System”);
lcd.setCursor(5, 1);
lcd.print(“FREEZING !”);
}
break;
case 30:
Display(“Temperature”, “Max:”, MaxTem, “F”);
break;
case 40:
Display(“Humidity”, “Now:”, Hum, “%”);
break;
case 50:
Display(“Humidity”, “Min:”, MinHum, “%”);
break;
case 60:
Display(“Humidity”, “Max:”, MaxHum, “%”);
if(MaxHum>80){
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Humidity High”);
lcd.setCursor(0, 1);
lcd.print(“Eval water needs”);
}
break;
case 70:
if(Moi>0){
Display(“Moisture”, “Now:”, Moi, “%”);
}
else{i=79;}
break;
case 80:
if(MinMoi>0){
Display(“Moisture”, “Min:”, MinMoi, “%”);
}
else{i=89;}
break;
case 90:
if(MaxMoi>0){
Display(“Moisture”, “Max:”, MaxMoi, “%”);
}
else{i=99;}
break;
case 100:
Display(“Lightlevel”, “Now:”, Lig, “%”);
break;
case 110:
Display(“Lightlevel”, “Min:”, MinLig, “%”);
break;
case 120:
Display(“Lightlevel”, “Max:”, MaxLig, “%”);
if(MaxLig<20){
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Lightlevel: Low”);
lcd.setCursor(0, 1);
lcd.print(“Is it night?”);
}
if(MaxLig>90){
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Lightlevel: High”);
lcd.setCursor(0, 1);
lcd.print(“Awesome !”);
}
i=0;
break;
}
i++;
delay(200);
}

void Display(char* Name, char* Time, float Value, char* Unit ) {
// Display a reading
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(Name);
lcd.setCursor(0, 1);
lcd.print(Time);
lcd.setCursor(5, 1);
lcd.print(Value);
lcd.setCursor(11, 1);
lcd.print(Unit);
}

Comments Off on Code



Comments are closed.

  • Projects

    • 2017
      • Artistic Prosthetic
      • Cell Protobox Activity
        • Background
        • Overview and Lesson Plan
        • Pictures from the Activity
        • Final Prototypes from the Activity
        • Recount of the Activity
        • Demo Day with PDI Students
        • Final Protobox
        • Next Steps
        • Vision
      • Hue Harmony
        • Project Scope
          • HueHarmony2.ino
          • Sampler_12bit.ino
        • Future Development
        • User Feedback
        • Research
      • infinish.ed
        • Proposed Solution – Unfini-shed
        • Proposed Solution – infinish.ed
        • User Experience Mapping
        • Design Justification
        • Roadblocks/Challenges
        • User Feedback
        • Conclusion
      • Pop-Up Symphony
      • Saltwater Greenhouse
      • Smart Protection Brace
        • Background Research
        • Initial Prototype
        • Iterations and Second Prototype
        • Next Steps
        • Potential Methods
        • User Group
    • 2016
      • Creation Station: An Interactive Kiosk
        • User Group
        • Feedback #1: Oakwood Community Dinner-November 14th, 2016
        • Feedback #2: Uncle Sam’s Bus Stop-November 15th, 2016
        • Feedback #3: Farmer’s Market- November 19th, 2016
        • Prototype and Final Build of the Kiosk
        • Final Testing and Final Thoughts
      • ElektroTone
      • Furnäture
      • Media Sanctuary Mobile Experience
        • Prototype 1
        • Prototype 2
        • Prototype 3
        • Next Steps
        • Presentation Slides
      • ObservaStory
        • Background Research
        • First Iteration
        • Second Iteration
        • Evaluation & Dissemination
      • People Library
        • Target User Group
        • Primary Iteration: The Event
        • Secondary Iteration: The System
          • The Website
          • The App
        • User Feedback: The Process
        • The Final Product
      • Physics Plank
        • Physics Plank 1.0
          • Design
          • User Feedback
        • Physics Plank 2.0
          • Design
          • User Feedback
        • Next Steps
          • Ideal Code and Construction
      • Portable Foundation Finder (PFF)
        • Background Research
        • Customer Discovery
          • Personas
          • Survey Responses
        • Prototype
        • User Testing
        • Working Demo
    • 2015
      • Alien Adaptation
        • Target User Group
        • First School Visit (September 28, 2015) – Prototype #1
        • Second School Visit (October 15, 2015) – Prototype #2
        • Third School Visit (November 9, 2015) – Prototype #3
        • Fourth School Visit (December 10th, 2015) – Prototype #4
        • Background Research
        • Alien Cards
        • Methods of Organization
        • Other Resources
      • Zoe the Green Monkey
        • Background Research
        • Evaluation & Dissemination
        • Sources for Further Teaching
      • Recipe Ratios
        • School 2 Visits
        • Background Research and Information
        • Context
        • Evaluation & Assessment
      • Space Race
        • Background Research
        • Evaluation and Assessment
        • Field Work : 1st Visit to School 2
        • Field Work : 2nd Visit to School 2
        • Field Work : 3rd Visit to School 2
        • Field Work : Final Visit to School 2
      • Rhythmatic
        • Overview/Background Research
        • User Research & Design Specifications
        • Lesson Plan
        • User Testing
        • Ethnographic Observations
        • Final Interface Design
    • 2014
      • Ghanaian Solar Heat Collection
        • Solar Production of Adinkra Ink
          • Adinkra Ink Background Information
            • Interview with Mae-Ling Lokko
            • Production of Adinkra Ink
        • Solar Production of Biochar
          • Biochar Information
          • Heliostat Development
            • Codes and Hardware
            • Phase 1: Small setup
            • Phase 2: Medium Setup
            • Phase 3: Future Design Considerations
          • Interviews with Marianne Nyman and Alex Allen
          • Planning the process
          • Prototype Design Process Images
        • Prototype Iterations
        • Testing
        • Future Prospects
      • Cheap Sensors for Quality Education
        • Building the Sensor
        • CSnap Integration for Data Visualization
        • Future Work
        • Hardware
        • Previous Iterations
        • Professional Development Integration
          • Compost Computing PD Outline
        • Transferring Data from Arduino to CSnap
        • Code (Integration with SD card data collection)
          • SD Card Readout Example
        • Code (Temperature and Humidity sensors only)
      • Condom Vending Machine
        • Cultural Background
        • Why Open Source?
        • Screen Printing Vs. Stickers
          • Hints for stickers!
        • Intitial Design Ideas
          • Initial Designs
        • Prototypes and feedback
        • Final Design
        • Feedback
        • Future Plans
      • Music & Sound: Earthquake Simulator
        • Prototyping & Iterations
          • Rounds 1 & 2
          • Round 3: Final Prototype
        • Field-Testing: User Feedback
        • How-To/DIY Projects
        • Future Testing
        • Dissemination
    • 2013
      • Edu-Ponics
        • The Community Garden
        • The Tower
        • The Monitoring Unit
          • Code
          • Prototype
        • Dissemination
        • User Feedback
        • About
      • Fraction Bot
        • Future Iterations
        • Primary Market Research
        • Prototyping/Testing
        • Source Code–Please Use
      • Ghana Outreach Solar Reflector
        • Cultural Background
        • Partnership with KNUST
        • Prototyping
          • Initial Mock-up
          • Lamination
          • Plywood Model
          • Reaction Chamber
          • Stainless Steel Ribs
        • Testing
        • Future Iterations
      • iQube
      • Lean Green Clean Machine
        • Background
        • Redesign Proposal
      • Music Factory
        • Prototype
        • Field Testing
        • Dissemination
      • Nutrition Kitchen
        • The Game
        • Learning About Nutrition
        • Children’s Reactions and Results
      • Solar Tracker
    • 2012
      • 2 Fast, 2 Curious
        • Learning Objectives
        • Make It Yourself!
          • Hardware
          • The Code
        • Responses
        • The Game
        • Downloads
      • Apollo 2 1/4
        • Children’s Reactions
        • Final Trip Notes
        • Fraction Practice
        • Materials & Software Used
        • Source Code
      • Coordinate Kinection
        • The Game
          • How to Play
          • Screenshots
        • Student Reactions
        • Do It Yourself
          • main.cpp
          • Instructions
          • Download
      • Discover The Universe
      • Power Up!
        • Make Your Own
        • Platform Theory
          • Software Theory
        • Research and Development
        • Student Reaction
      • Squid Learn
        • Building the Lesson Plan
        • How It’s Made
        • Research and Iterations
          • 1st Visit
          • 2nd Visit
          • 3rd Visit
        • Student Reactions
    • 2011
      • Alien Frontier
        • Downloads
        • The Process
          • Ethnographic Description
          • Ethnographic Description 1
          • Ethnographic Description 2
      • Cookie Creations
        • Cookie Creation Game
        • Classroom Process
        • Assessments and Surveys Used
        • Research
      • Fast Track
        • DIY
        • Learning Objectives
        • Materials
        • Response
        • Components
      • Make ’em Fresh
        • Make ’em Fresh: How It’s Made
          • Team Contributions
        • Make ’em Fresh: Research and Iterations
          • Early Concepts
          • Images: First and Second Visits
          • Future Iterations
        • Make ’em Fresh: Student Response
          • Pre- and Post-Testing
      • Rap Star
        • The Game
          • What?
          • When & Where?
          • Who?
          • Why?
        • Field Testing and Iterations
          • First Visit
          • Second Visit
          • Final Visit
          • Ethnographic Descriptions
        • What Now?
          • Conclusion
          • Future Iterations
          • Additional Images
      • Rush More
      • School House of Pop
        • Educational Goals
        • Student Response
        • Design Evolution
        • Future Design Aspirations
        • Culture and Society
        • Pictures at School

Theme: MistyLook by Sadish. WPMU Theme pack by WPMU-DEV.