code help needed please!

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 :slight_smile:

int time=0;
int counter=0;
int flag=LOW;

#include <LiquidCrystal.h>
LiquidCrystal lcd(10,11,12,13,14,15,16);

void setup(){
pinMode (12, OUTPUT);//d12 LED output
pinMode(9, INPUT);//d9 button input
lcd.print(“Lesson Time”);

void loop() {
int twister=analogRead(4);
int btn = digitalRead(8);

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;


if (btn==HIGH) {
Serial.println(“button pressed”);
counter = 0;

if(flag==HIGH) {

if(counter>=60) {
Serial.println(“counter is max”);
flag = LOW;


Three comments:

Hardware: Are you using a pull-up or pull-down resistor for the switch button? You need to.

Software: Your are reading the button at the top of the sketch but don't test for it till after your 1/2 second delay statement. You should do the read of the button just before you test for it in the if statement.
Also switches suffer from contact bounce, you should include debouncing steps in your program. The Button library is a popular way to read mechanical switches, Arduino Playground - HomePage


LiquidCrystal lcd(10,11,12,13,14,15,16);
pinMode (12, OUTPUT);//d12 LED output

So, is it the LCD or the LED that is connected to pin 12?

yeah thanks alot it was the output pins where both the same! thanks again :slight_smile: