Hallo
Sorry my bad english!!
I can't get my LCD to show a Light variable =(
My code:
#include "pitches.h"
#include <LCD5110.h>
const int maxi = 20;
const int mini = 1;
// The update interval
const int refresh = 500;
int ldrPin = 0;
int light = 0;
const int startFreq = 10000;
const int stopFreq = 15000;
// notes in the melody:
int melody[] = {
NOTE_G3, NOTE_G3, NOTE_G3, NOTE_DS3,0, NOTE_F3, NOTE_F3, NOTE_F3, NOTE_D3};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 4, 4, 2, 4, 4, 4, 4, 2 };
void setup(void)
{
LcdInitialise();
LcdClear();
gotoXY(12,0);
LcdString("NJA Light");
}
void loop(void)
{
light = analogRead(ldrPin);
light = light/10;
// Serial.print("Light reading = ");
// Serial.println(light);
delay(refresh);
// ************ START ******************
LcdInitialise();
gotoXY(1,2);
LcdString("Light:");
gotoXY(45,2);
LcdString(light); // !! This Line1 will not work!!
delay(1000);
if (light <mini){
// Serial.println("Dark");
delay(5000);
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 9; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(8);
}
} else if (light >maxi){
// Serial.println("High Sun!");
int i;
for (i = startFreq; i <= stopFreq; i++) {
tone(8, i);
delayMicroseconds(10);}
for (i = stopFreq; i >= startFreq; i--) {
tone(8, i);
delayMicroseconds(1000);}
noTone(8);
}
// ************ END
}
And i can't see what i do wrong, plz help me someone, somebody. (Then your will make a danish boy happy)
Thanks for helping