Hi, another newbie here!
I'm helping a friend with a university project (she's a landscape architect, so I'm not exactly doing her homework). The more important bit is her design but it also needs to be 'smart', and I'm trying to do
the 'smart' bit. Hence I'm here crying for help...oh, the irony...
Anyway, I quite enjoy messing around with it, but the deadline is approaching.
Here's what needs to happen:
There is a temperature sensor that needs to drive a stepper after reaching certain threshold.
Said threshold needs to be user adjustable (via buttons). Current temperature and current threshold need to be displayed on an LCD as well as state of motor - "going up" or "going down" for example.
Also, there should be a switch for when she needs to force the motor instead of wait for the sensor,
that needs another set of buttons and indication.
This is what would be really nice to have, however I'll probably end up with a more simplified version of it.
Here's where I'm at the moment:
I have the sensor (LM35) which turns on an LED after reaching a pre-set threshold.
Current temp and state are displayed on an LCD (Qapass 1602).
This is the code that works so far:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int inPin = 0; //sensor input
const int outPin = 8; // LED pin
const int treshold = 25; // temp treshold
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(outPin, OUTPUT);
}
void loop()
{
int value = analogRead(inPin);
long celsius = (value * 500L) / 1024; //10mV per C
Serial.print(celsius);
Serial.print(" Temp, C: ");
lcd.print(celsius);
lcd.setCursor(0, 1);
if (celsius > treshold) // if temp is higher than tresh elevate LED pin
{
digitalWrite(outPin, HIGH);
lcd.write("sh*t is hot");
}
else
{
digitalWrite(outPin, LOW);
lcd.write("it's cool");
}
delay(500); lcd.clear();
}
Here's what I'm struggling with:
- I'm having troubles adjusting the threshold via button press. How do I set this up?
- Formatting the LCD, how to properly display all four bits of data, a link to tutorial would be ok.
- Servo isn't working, it's glitch-y, only moves a bit at the start, tried a few ways, gave up on it.
- Motor is going to be a pain, but I'm not there yet (but I tried a few simple schemes and it works).
So yeah, the question is a bit broad at the the moment,
I guess I just have to read a book perhaps and try lots of stuff until I figure how
everything comes together, but it would be nice if you could give me a few pointers!
Cheers,
Milko

