hey I'm quite new to arduino, been learning at college our assignment was to make a device which would monitor room usage
my programme consists of a few components such as: a button,LCD screen,led light and a rotary angle sensor.
The basic concept is that when the programme starts up "lesson time" is displayed on the LCD and when the rotary angle sensor is twisted the screen with display 30, 60 or 90 (lesson times in mins); once the right lesson time is on screen the person presses the button to light the led for 30 ,60 or 90 mins and display on the screen ("time" started) and maybe a count down on the screen.
I've got the rotary angle sensor to work with the screen so that it displays 30, 60, 90 however when the button is pressed strange symbols appear on the LCD screen kind of like Chinese symbols i have no idea why this is happening. I'll post my code any help will be great thanks! p.s i havent finished the code and button obv won't stay on for 30, 60 or 90 mins! thanks ![]()
int time=0;
int counter=0;
int flag=LOW;
#include <LiquidCrystal.h>
LiquidCrystal lcd(10,11,12,13,14,15,16);
void setup(){
Serial.begin(9600);
pinMode (12, OUTPUT);//d12 LED output
pinMode(9, INPUT);//d9 button input
lcd.begin(16,2);
lcd.print("Lesson Time");
}
void loop() {
int twister=analogRead(4);
int btn = digitalRead(8);
Serial.println(twister);
if (twister>=1 && twister<=256)time=0;
if (twister>=257 && twister<=513)time=30;
if (twister>=514 && twister<=771)time=60;
if (twister>=772 && twister<=1023) time=90;
lcd.clear();
lcd.print(time);
delay(500);
if (btn==HIGH) {
Serial.println("button pressed");
flag=HIGH;
counter = 0;
digitalWrite(12,HIGH);
}
if(flag==HIGH) {
Serial.println(counter);
counter++;
}
if(counter>=60) {
Serial.println("counter is max");
flag = LOW;
digitalWrite(12,LOW);
}
}