Show Posts
Pages: 1 ... 31 32 [33] 34 35 ... 40
481  Using Arduino / Displays / Re: Easy way to dim parallel LCD backlight with a photoresitor on: February 10, 2012, 08:03:55 pm
Been trying to get a decimal place by using fractions for a few hours, cant get it to compile though smiley-sad

Code:
/*
 
 
 The circuit:
 * LDR connected to analog pin 0.
 * LED / transistor connected from digital pin 3 to ground
 
 * LCD RS pin to digital pin 7
 * LCD EN pin to digital pin 8
 * LCD D4 pin to digital pin 9
 * LCD D5 pin to digital pin 10
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 12
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 * LCD LED+ (15) pin transistor
 * LCD LED- (16) to ground
 
 * Thermisor divider 1 output to analog pin 1
 * Thermisor divider 2 output to analog pin 2
 
 
 */

// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the lDR is attached to
const int analogOutPin = 3; // Analog output pin that the LED is attached to

const int minLight = 100;        // at or below this light level, use minimum backlight intensity
const int maxLight = 900;       // at or above this light level, use maximum backlight intensity
const int minBacklight = 5;      // lowest backlight intensity to use
const int maxBacklight = 255;  // highest backlight intensity to use

unsigned int frac;


// include the library code:
#include <LiquidCrystal.h>

#include <math.h>

double Thermister(int RawADC) {
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;            // Convert Kelvin to Celcius

  return Temp;
}


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);


int sensorValue = 0;        // value read from the LDR
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  lcd.begin(16, 2);
  delay(100);
  pinMode(13, OUTPUT);  

}

void loop() {
  // read the analog in value:
  analogRead(analogInPin);
  delay(100);
  sensorValue = analogRead(analogInPin);            
  // map it to the range of the analog out:
  outputValue = map(constrain(sensorValue, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);          

  // print the results to the serial monitor:
  Serial.print("sensor = " );                      
  Serial.print(sensorValue);      
  Serial.print("\t output = ");      
  Serial.println(outputValue);  

 
  // Temperature 1 print
  lcd.clear();

  lcd.setCursor(0,0);
  lcd.print ("Out: ");
  lcd.print(int(Thermister(analogRead(1))));
  lcd.print (".");
  
  frac = (Thermister(analogRead(1)) - int (Thermister(analogRead(1)) * 10;
  lcd.print(frac, DEC);


  lcd.print((char)223);
  lcd.print ("c");


  Serial.print ("Temp1=");
  Serial.println(int(Thermister(analogRead(1))));  // display temp

  // Temperature 2 print
  //lcd.setCursor(0,1);
  //lcd.print(int(Thermister(analogRead(2))));


  //lcd.print((char)223);
  //lcd.print ("c");

  //Serial.print ("Temp2=");
  //Serial.println(int(Thermister(analogRead(2))));  // display temp


  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(1000);                    
}
482  Using Arduino / Displays / Re: Easy way to dim parallel LCD backlight with a photoresitor on: February 10, 2012, 06:58:29 pm
Thanks again DC!

I am just testing it out at the moment, I have a probe outside and I think its just below 0 right now according to another therm, but the arduino is reporting a solid 0?

How would I set it to display a decimal point ie 0.6c?

Here is what I have so far smiley

Code:
/*
 
 
 The circuit:
 * LDR connected to analog pin 0.
 * LED / transistor connected from digital pin 3 to ground
 
 * LCD RS pin to digital pin 7
 * LCD EN pin to digital pin 8
 * LCD D4 pin to digital pin 9
 * LCD D5 pin to digital pin 10
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 12
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 * LCD LED+ (15) pin transistor
 * LCD LED- (16) to ground
 
 * Thermisor divider 1 output to analog pin 1
 * Thermisor divider 2 output to analog pin 2
 
 
 */

// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the lDR is attached to
const int analogOutPin = 3; // Analog output pin that the LED is attached to

const int minLight = 100;        // at or below this light level, use minimum backlight intensity
const int maxLight = 900;       // at or above this light level, use maximum backlight intensity
const int minBacklight = 5;      // lowest backlight intensity to use
const int maxBacklight = 255;  // highest backlight intensity to use

// include the library code:
#include <LiquidCrystal.h>

#include <math.h>

double Thermister(int RawADC) {
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;            // Convert Kelvin to Celcius

  return Temp;
}


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);


int sensorValue = 0;        // value read from the LDR
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  lcd.begin(16, 2);
  delay(100);
  pinMode(13, OUTPUT); 

}

void loop() {
  // read the analog in value:
  analogRead(analogInPin);
  delay(100);
  sensorValue = analogRead(analogInPin);           
  // map it to the range of the analog out:
  outputValue = map(constrain(sensorValue, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print(sensorValue);     
  Serial.print("\t output = ");     
  Serial.println(outputValue); 

 
  // Temperature 1 print
  lcd.clear();

  lcd.setCursor(0,0);
  lcd.print ("Out: ");
  lcd.print(int(Thermister(analogRead(1))));


  lcd.print((char)223);
  lcd.print ("c");


  Serial.print ("Temp1=");
  Serial.println(int(Thermister(analogRead(1))));  // display temp

  // Temperature 2 print
  //lcd.setCursor(0,1);
  //lcd.print(int(Thermister(analogRead(2))));


  //lcd.print((char)223);
  //lcd.print ("c");

  //Serial.print ("Temp2=");
  //Serial.println(int(Thermister(analogRead(2))));  // display temp


  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(1000);                     
}









483  Using Arduino / Project Guidance / Re: Humidity sensor on: February 10, 2012, 09:22:00 am
Thanks for fixing the typo smiley

That's re-assuring that you have used them already. I can't get the datasheet to load at the moment from the ebay listing  - http://www.egochina.net.cn/eBay/Download/DHT11.pdf

how do you interface to the sensors?

484  Community / Exhibition / Gallery / Arduino's in permanent projects? on: February 10, 2012, 07:13:54 am
Hi all. I'm just wondering purely out of interest how many arduinos (or homemade whatever) you use around the place in permanent projects? If so what projects?

I have not completed a project yet but there are so many I want to do so I can image there will be a fair few working away around my house soon smiley
485  Using Arduino / Project Guidance / Humidity sensor on: February 10, 2012, 07:09:02 am
Hi all, Id like to add humidity sensing to my project.

I have never tried or even seen a humidity sensor so I'm a bit in the dark here. I don't want to spend much on them. Searching ebay I have come up with these..

http://www.ebay.co.uk/itm/4PCS-X-DHT11-Digital-Humidity-Temperature-Sensor-/200627851859?pt=LH_DefaultDomain_0&hash=item2eb65a1253#ht_4159wt_1163
http://www.ebay.co.uk/itm/2-Humirel-Humidity-Sensor-HS1101-Arduino-Hygrometer-/320743007075?pt=UK_BOI_Industrial_Automation_Control_ET&hash=item4aadc5e363#ht_2953wt_1048

One of them does temperature too but that is not really required although I could use that instead of NTC's

Are there any better options?
486  Using Arduino / Project Guidance / Re: New First Project on: February 06, 2012, 05:35:17 pm
I have messed about with some of the stuff from RF solutions. I was going to make a wireless RGB LED controller. I have got a 4 way decoder + encoder that you can set to latching or non-latching, which is not very helpful because I needed 2 momentary outputs, and one latching to control the power to the PIC and the PSU that runs the RGB stuff.

I didn't get around to working out how to make a latch but its on my list of to'do's!
487  Using Arduino / Project Guidance / Re: Remote Voltage Read on: February 06, 2012, 05:28:28 pm
should be simple enough mate, set up a voltage divider to make a voltage in the range of 0-5v then feed that into one of the arduino adc inputs
488  Using Arduino / Project Guidance / Re: LCD display changing text with button press on: February 06, 2012, 07:19:09 am
Maybe I should have posted this in the display sub-forum?
489  Using Arduino / Project Guidance / LCD display changing text with button press on: February 05, 2012, 07:39:08 pm
Hi all. I have some RGB LED controllers and they have a sequence which changes on pulling an input on the uC low. There are two inputs, one selects the program, the other sets variables such as speed in that program. Here is the sequence http://www.bigclive.com/datagreen.htm

Because the chip is a pre-programmed PIC there is no real way of me knowing which program I'm in.

I want to use an arduino to display this on a LCD.  I want to basically input all the program names and make them scroll on the LCD with a low input on a pin. I could sync it by pressing both buttons together (which reverts to prog 1 on the PIC) or sync it manually so I think it will be ok to run the two uC's independently.

I'm not sure how to code an arduino to change display on keypress?

Thanks
490  Using Arduino / Project Guidance / Re: Cheapest possible Arduino (DIY) on: February 03, 2012, 11:26:46 am
cheers guys, I will have a mess about later and update it.

Here is the schematic that I created the board from - a bit messy and please ignore the single headers lol

491  Using Arduino / Project Guidance / Re: Cheapest possible Arduino (DIY) on: February 03, 2012, 10:42:16 am
Knocked up a board, I think it should work hopefully. Do you guys have some suggestions?
492  Using Arduino / Displays / Re: Easy way to dim parallel LCD backlight with a photoresitor on: February 02, 2012, 07:42:26 am
Thanks DC, I don't understand exactly how the function is working but I understand the principles.

Also a bit confused as to what you mean by treating the open & short circuit cases separately?
I think maybe I need to add a case somehow for sensor reading = 0 and sensor reading = 1024?

Could I use an else - if function.. i.e. if reading is 0 = Lcd displays - sensor disconnected, else if reading is 1024 = Lcd displays - short circuit?

Thanks

Dan
493  Using Arduino / Project Guidance / Re: Cheapest possible Arduino (DIY) on: February 01, 2012, 12:53:42 pm
Got the Sparkfun Lib but can only find SMD versions of the 168 in there?
494  Using Arduino / Project Guidance / Re: Cheapest possible Arduino (DIY) on: February 01, 2012, 12:46:46 pm
Thanks guys. I'm in the UK but those NKC boards look really good! I'll have to check for shipping info. I can solder SMD no worries but I'm after something that I can easily program, hence thinking to use a Uno - and I'm a bit of a noob?

Thanks for the heads up on the standalone link that looks like a good info source. Just looking at Eagle though and I can't find a library with the Atmega 168 or 328 anywhere. I've looked in the sparkfun, atmel, & avr_7 libs, anyone know if I'm just being stupid? lol

Thanks

495  Using Arduino / Project Guidance / Cheapest possible Arduino (DIY) on: February 01, 2012, 10:09:37 am
Hi all, I'm getting to the point now that I would like to leave a couple of projects working that I have built around the Arduino.

Could someone point me in the direction of making my own Arduino with the minimum required components? I will be programming chips in my Uno more than likely then swapping them out so I don't need any USB bridge stuff

Thanks
Pages: 1 ... 31 32 [33] 34 35 ... 40