Pages: [1]   Go Down
Author Topic: don't mind me ... just testing in here...  (Read 758 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

The DHT circuit:
 
 * Connect pin 1 (on the left) of the sensor to +5V
 * Connect pin 2 of the sensor to whatever your DHTPIN (smiley-cool
 * Connect pin 4 (on the right) of the sensor to GROUND
 * Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor 

The LDR circuit: (photocell)
 * Connect LDR in series with 10K resistor
 * Connect LDR free end to 5V
 * Connect 10k resistor free end to ground
 * Connect LDR/resistor junction to pin A0
 
The PushButton Circuit
 * Connect 10k resistor in series with normally open momentary button
 * Connect 10k resistor free end to 5V
 * Connect push button free end to ground
 * Connect push button/resistor junction to pin 9
Code pieced together by Thomas Amely 6/17/2013
This example code is in the public domain.
 */

// include the library code:
#include <LiquidCrystal.h>
#include "DHT.h"  // ADAFRUIT DHT or compatible branch library required

// Uncomment whatever type you're using!, Comment the rest!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)


// Define Global variables
const int DHTPIN = 8;  // Pin the humidity/temp sensor is connected to
const int LDRPIN = A0; // Pin the photocell is connected to
const int BUTTON = 9;  // PIn the push button is connected to.

LiquidCrystal lcd(2,3,4,5,6,7);// initialize the library with the numbers of the interface pins
DHT dht(DHTPIN, DHTTYPE);  // Initialize dht with parameters (pin numbers)

void setup() {
  // Set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.print("Push for refresh...");
  // Set pin function
  pinMode (BUTTON,INPUT); // Set Button as input
}

void loop() {
  // Local Variables for data collections
  float rh; // Relative Humidity
  float tc; // Temperature in Celcius 
  float tf; // Temperature in Fahrenheit
  int ll;   // Light Level
  
  // Check for button input
  if (digitalRead(BUTTON) == 0){  // Check for button bein pushed 0=pushed 1= not pushed
    rh = dht.readHumidity();    // Get relative humidity
    tc = dht.readTemperature(); // Get temperature in Celcius and save as tc
    tf = tc*1.8+32;             // Convert temperature to Fahrenheit and save as tf
    ll = analogRead(LDRPIN)/10; /* Divide by 10 for a rough 1 to 100 scale
                                   Use "map" function for a more precise mapping */
                                   
    lcd.clear();        // Clear old data and reset cursor
    lcd.print("LL:"); 
    lcd.print(ll);      // Write light level to lcd
    lcd.print(" RH:");
    lcd.print(rh);      // Write relative humidity to lcd
    lcd.print("%");
    lcd.setCursor(0,1); // Set cursor to first position of second line (x,y) zero-indexed
    lcd.print("T:");
    lcd.print(tc);      // Write temperature in Celius to lcd
    lcd.print("C ");
    lcd.print(tf);      // Write temperature in Fahrenheit to lcd
    lcd.print("F ");
    
  }
  
}


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
[quote]
[color=#7E7E7E]/*[/color]
[color=#7E7E7E]The LCD circuit:[/color]
[color=#7E7E7E] * LCD RS pin to digital pin 2[/color]
[color=#7E7E7E] * LCD Enable pin to digital pin 3[/color]
[color=#7E7E7E] * LCD D4 pin to digital pin 4[/color]
[color=#7E7E7E] * LCD D5 pin to digital pin 5[/color]
[color=#7E7E7E] * LCD D6 pin to digital pin 6[/color]
[color=#7E7E7E] * LCD D7 pin to digital pin 7[/color]
[color=#7E7E7E] * LCD R/W pin to ground[/color]
[color=#7E7E7E] * 10K Potentiometer:[/color]
[color=#7E7E7E] * ends to +5V and ground[/color]
[color=#7E7E7E] * wiper to LCD VO pin (pin 3)[/color]

[color=#7E7E7E]The DHT circuit:[/color]
[color=#7E7E7E] [/color]
[color=#7E7E7E] * Connect pin 1 (on the left) of the sensor to +5V[/color]
[color=#7E7E7E] * Connect pin 2 of the sensor to whatever your DHTPIN (8)[/color]
[color=#7E7E7E] * Connect pin 4 (on the right) of the sensor to GROUND[/color]
[color=#7E7E7E] * Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor [/color]

[color=#7E7E7E]The LDR circuit: (photocell)[/color]
[color=#7E7E7E] * Connect LDR in series with 10K resistor[/color]
[color=#7E7E7E] * Connect LDR free end to 5V[/color]
[color=#7E7E7E] * Connect 10k resistor free end to ground[/color]
[color=#7E7E7E] * Connect LDR/resistor junction to pin A0[/color]
[color=#7E7E7E] [/color]
[color=#7E7E7E]The PushButton Circuit[/color]
[color=#7E7E7E] * Connect 10k resistor in series with normally open momentary button[/color]
[color=#7E7E7E] * Connect 10k resistor free end to 5V[/color]
[color=#7E7E7E] * Connect push button free end to ground[/color]
[color=#7E7E7E] * Connect push button/resistor junction to pin 9[/color]
[color=#7E7E7E]Code pieced together by Thomas Amely 6/17/2013[/color]
[color=#7E7E7E]This example code is in the public domain.[/color]
[color=#7E7E7E] */[/color]

[color=#7E7E7E]// include the library code:[/color]
#include <[color=#CC6600]LiquidCrystal[/color].h>
#include [color=#006699]"DHT.h"[/color]  [color=#7E7E7E]// ADAFRUIT DHT or compatible branch library required[/color]

[color=#7E7E7E]// Uncomment whatever type you're using!, Comment the rest![/color]
#define DHTTYPE DHT11   [color=#7E7E7E]// DHT 11 [/color]
[color=#7E7E7E]//#define DHTTYPE DHT22   // DHT 22  (AM2302)[/color]
[color=#7E7E7E]//#define DHTTYPE DHT21   // DHT 21 (AM2301)[/color]


[color=#7E7E7E]// Define Global variables[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] DHTPIN = 8;  [color=#7E7E7E]// Pin the humidity/temp sensor is connected to[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] LDRPIN = A0; [color=#7E7E7E]// Pin the photocell is connected to[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] BUTTON = 9;  [color=#7E7E7E]// PIn the push button is connected to.[/color]

[color=#CC6600]LiquidCrystal[/color] lcd(2,3,4,5,6,7);[color=#7E7E7E]// initialize the library with the numbers of the interface pins[/color]
DHT dht(DHTPIN, DHTTYPE);  [color=#7E7E7E]// Initialize dht with parameters (pin numbers)[/color]

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
  [color=#7E7E7E]// Set up the LCD's number of columns and rows: [/color]
  lcd.[color=#CC6600]begin[/color](16, 2);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Push for refresh..."[/color]);
  [color=#7E7E7E]// Set pin function[/color]
  [color=#CC6600]pinMode[/color] (BUTTON,[color=#006699]INPUT[/color]); [color=#7E7E7E]// Set Button as input[/color]
}

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
  [color=#7E7E7E]// Local Variables for data collections[/color]
  [color=#CC6600]float[/color] rh; [color=#7E7E7E]// Relative Humidity[/color]
  [color=#CC6600]float[/color] tc; [color=#7E7E7E]// Temperature in Celcius  [/color]
  [color=#CC6600]float[/color] tf; [color=#7E7E7E]// Temperature in Fahrenheit [/color]
  [color=#CC6600]int[/color] ll;   [color=#7E7E7E]// Light Level[/color]
  
  [color=#7E7E7E]// Check for button input[/color]
  [color=#CC6600]if[/color] ([color=#CC6600]digitalRead[/color](BUTTON) == 0){  [color=#7E7E7E]// Check for button bein pushed 0=pushed 1= not pushed[/color]
    rh = dht.readHumidity();    [color=#7E7E7E]// Get relative humidity[/color]
    tc = dht.[color=#CC6600]readTemperature[/color](); [color=#7E7E7E]// Get temperature in Celcius and save as tc[/color]
    tf = tc*1.8+32;             [color=#7E7E7E]// Convert temperature to Fahrenheit and save as tf[/color]
    ll = [color=#CC6600]analogRead[/color](LDRPIN)/10; [color=#7E7E7E]/* Divide by 10 for a rough 1 to 100 scale [/color]
[color=#7E7E7E]                                   Use "map" function for a more precise mapping */[/color]
                                   
    lcd.[color=#CC6600]clear[/color]();        [color=#7E7E7E]// Clear old data and reset cursor[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"LL:"[/color]); 
    lcd.[color=#CC6600]print[/color](ll);      [color=#7E7E7E]// Write light level to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]" RH:"[/color]);
    lcd.[color=#CC6600]print[/color](rh);      [color=#7E7E7E]// Write relative humidity to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"%"[/color]);
    lcd.[color=#CC6600]setCursor[/color](0,1); [color=#7E7E7E]// Set cursor to first position of second line (x,y) zero-indexed[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"T:"[/color]);
    lcd.[color=#CC6600]print[/color](tc);      [color=#7E7E7E]// Write temperature in Celius to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"C "[/color]);
    lcd.[color=#CC6600]print[/color](tf);      [color=#7E7E7E]// Write temperature in Fahrenheit to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"F "[/color]);
    
  }
  
}


[/quote]
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

The DHT circuit:
 
 * Connect pin 1 (on the left) of the sensor to +5V
 * Connect pin 2 of the sensor to whatever your DHTPIN (8)
 * Connect pin 4 (on the right) of the sensor to GROUND
 * Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

The LDR circuit: (photocell)
 * Connect LDR in series with 10K resistor
 * Connect LDR free end to 5V
 * Connect 10k resistor free end to ground
 * Connect LDR/resistor junction to pin A0
 
The PushButton Circuit
 * Connect 10k resistor in series with normally open momentary button
 * Connect 10k resistor free end to 5V
 * Connect push button free end to ground
 * Connect push button/resistor junction to pin 9
Code pieced together by Thomas Amely 6/17/2013
This example code is in the public domain.
 */

// include the library code:
#include <LiquidCrystal.h>
#include "DHT.h"  // ADAFRUIT DHT or compatible branch library required

// Uncomment whatever type you're using!, Comment the rest!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)


// Define Global variables
const int DHTPIN = 8;  // Pin the humidity/temp sensor is connected to
const int LDRPIN = A0; // Pin the photocell is connected to
const int BUTTON = 9;  // PIn the push button is connected to.

LiquidCrystal lcd(2,3,4,5,6,7);// initialize the library with the numbers of the interface pins
DHT dht(DHTPIN, DHTTYPE);  // Initialize dht with parameters (pin numbers)

void setup() {
  // Set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.print("Push for refresh...");
  // Set pin function
  pinMode (BUTTON,INPUT); // Set Button as input
}

void loop() {
  // Local Variables for data collections
  float rh; // Relative Humidity
  float tc; // Temperature in Celcius 
  float tf; // Temperature in Fahrenheit
  int ll;   // Light Level
 
  // Check for button input
  if (digitalRead(BUTTON) == 0){  // Check for button bein pushed 0=pushed 1= not pushed
    rh = dht.readHumidity();    // Get relative humidity
    tc = dht.readTemperature(); // Get temperature in Celcius and save as tc
    tf = tc*1.8+32;             // Convert temperature to Fahrenheit and save as tf
    ll = analogRead(LDRPIN)/10; /* Divide by 10 for a rough 1 to 100 scale
                                   Use "map" function for a more precise mapping */
                                   
    lcd.clear();        // Clear old data and reset cursor
    lcd.print("LL:"); 
    lcd.print(ll);      // Write light level to lcd
    lcd.print(" RH:");
    lcd.print(rh);      // Write relative humidity to lcd
    lcd.print("%");
    lcd.setCursor(0,1); // Set cursor to first position of second line (x,y) zero-indexed
    lcd.print("T:");
    lcd.print(tc);      // Write temperature in Celius to lcd
    lcd.print("C ");
    lcd.print(tf);      // Write temperature in Fahrenheit to lcd
    lcd.print("F ");
   
  }
 
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
[color=#7E7E7E]/*[/color]
[color=#7E7E7E]The LCD circuit:[/color]
[color=#7E7E7E] * LCD RS pin to digital pin 2[/color]
[color=#7E7E7E] * LCD Enable pin to digital pin 3[/color]
[color=#7E7E7E] * LCD D4 pin to digital pin 4[/color]
[color=#7E7E7E] * LCD D5 pin to digital pin 5[/color]
[color=#7E7E7E] * LCD D6 pin to digital pin 6[/color]
[color=#7E7E7E] * LCD D7 pin to digital pin 7[/color]
[color=#7E7E7E] * LCD R/W pin to ground[/color]
[color=#7E7E7E] * 10K Potentiometer:[/color]
[color=#7E7E7E] * ends to +5V and ground[/color]
[color=#7E7E7E] * wiper to LCD VO pin (pin 3)[/color]

[color=#7E7E7E]The DHT circuit:[/color]
[color=#7E7E7E] [/color]
[color=#7E7E7E] * Connect pin 1 (on the left) of the sensor to +5V[/color]
[color=#7E7E7E] * Connect pin 2 of the sensor to whatever your DHTPIN (8)[/color]
[color=#7E7E7E] * Connect pin 4 (on the right) of the sensor to GROUND[/color]
[color=#7E7E7E] * Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor [/color]

[color=#7E7E7E]The LDR circuit: (photocell)[/color]
[color=#7E7E7E] * Connect LDR in series with 10K resistor[/color]
[color=#7E7E7E] * Connect LDR free end to 5V[/color]
[color=#7E7E7E] * Connect 10k resistor free end to ground[/color]
[color=#7E7E7E] * Connect LDR/resistor junction to pin A0[/color]
[color=#7E7E7E] [/color]
[color=#7E7E7E]The PushButton Circuit[/color]
[color=#7E7E7E] * Connect 10k resistor in series with normally open momentary button[/color]
[color=#7E7E7E] * Connect 10k resistor free end to 5V[/color]
[color=#7E7E7E] * Connect push button free end to ground[/color]
[color=#7E7E7E] * Connect push button/resistor junction to pin 9[/color]
[color=#7E7E7E]Code pieced together by Thomas Amely 6/17/2013[/color]
[color=#7E7E7E]This example code is in the public domain.[/color]
[color=#7E7E7E] */[/color]

[color=#7E7E7E]// include the library code:[/color]
#include <[color=#CC6600]LiquidCrystal[/color].h>
#include [color=#006699]"DHT.h"[/color]  [color=#7E7E7E]// ADAFRUIT DHT or compatible branch library required[/color]

[color=#7E7E7E]// Uncomment whatever type you're using!, Comment the rest![/color]
#define DHTTYPE DHT11   [color=#7E7E7E]// DHT 11 [/color]
[color=#7E7E7E]//#define DHTTYPE DHT22   // DHT 22  (AM2302)[/color]
[color=#7E7E7E]//#define DHTTYPE DHT21   // DHT 21 (AM2301)[/color]


[color=#7E7E7E]// Define Global variables[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] DHTPIN = 8;  [color=#7E7E7E]// Pin the humidity/temp sensor is connected to[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] LDRPIN = A0; [color=#7E7E7E]// Pin the photocell is connected to[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] BUTTON = 9;  [color=#7E7E7E]// PIn the push button is connected to.[/color]

[color=#CC6600]LiquidCrystal[/color] lcd(2,3,4,5,6,7);[color=#7E7E7E]// initialize the library with the numbers of the interface pins[/color]
DHT dht(DHTPIN, DHTTYPE);  [color=#7E7E7E]// Initialize dht with parameters (pin numbers)[/color]

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
  [color=#7E7E7E]// Set up the LCD's number of columns and rows: [/color]
  lcd.[color=#CC6600]begin[/color](16, 2);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Push for refresh..."[/color]);
  [color=#7E7E7E]// Set pin function[/color]
  [color=#CC6600]pinMode[/color] (BUTTON,[color=#006699]INPUT[/color]); [color=#7E7E7E]// Set Button as input[/color]
}

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
  [color=#7E7E7E]// Local Variables for data collections[/color]
  [color=#CC6600]float[/color] rh; [color=#7E7E7E]// Relative Humidity[/color]
  [color=#CC6600]float[/color] tc; [color=#7E7E7E]// Temperature in Celcius  [/color]
  [color=#CC6600]float[/color] tf; [color=#7E7E7E]// Temperature in Fahrenheit [/color]
  [color=#CC6600]int[/color] ll;   [color=#7E7E7E]// Light Level[/color]
  
  [color=#7E7E7E]// Check for button input[/color]
  [color=#CC6600]if[/color] ([color=#CC6600]digitalRead[/color](BUTTON) == 0){  [color=#7E7E7E]// Check for button bein pushed 0=pushed 1= not pushed[/color]
    rh = dht.readHumidity();    [color=#7E7E7E]// Get relative humidity[/color]
    tc = dht.[color=#CC6600]readTemperature[/color](); [color=#7E7E7E]// Get temperature in Celcius and save as tc[/color]
    tf = tc*1.8+32;             [color=#7E7E7E]// Convert temperature to Fahrenheit and save as tf[/color]
    ll = [color=#CC6600]analogRead[/color](LDRPIN)/10; [color=#7E7E7E]/* Divide by 10 for a rough 1 to 100 scale [/color]
[color=#7E7E7E]                                   Use "map" function for a more precise mapping */[/color]
                                   
    lcd.[color=#CC6600]clear[/color]();        [color=#7E7E7E]// Clear old data and reset cursor[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"LL:"[/color]); 
    lcd.[color=#CC6600]print[/color](ll);      [color=#7E7E7E]// Write light level to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]" RH:"[/color]);
    lcd.[color=#CC6600]print[/color](rh);      [color=#7E7E7E]// Write relative humidity to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"%"[/color]);
    lcd.[color=#CC6600]setCursor[/color](0,1); [color=#7E7E7E]// Set cursor to first position of second line (x,y) zero-indexed[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"T:"[/color]);
    lcd.[color=#CC6600]print[/color](tc);      [color=#7E7E7E]// Write temperature in Celius to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"C "[/color]);
    lcd.[color=#CC6600]print[/color](tf);      [color=#7E7E7E]// Write temperature in Fahrenheit to lcd[/color]
    lcd.[color=#CC6600]print[/color]([color=#006699]"F "[/color]);
    
  }
  
}

Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 25
Posts: 1147
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I dont mind at all.

When you're done, and it does not need to be preserved for prosperity, you can delete the entire thread. (Or click the Moderator button to get it done.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good thinking!! Thanks!

Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ready for deletion?
Hopefully reply #2 was what you were after.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: