HELP! 8x8 matrix ALARM CLOCK

Hi guys,

this is my first post to the forum. I'm a Parsons student in NYC and am in desperate need of help for a final project of mine that is due tomorrow.

I made an 8x8 led matrix display for the clock and everything works but I cannot get the alarm to set.

I have five buttons

one is held for alarm mode and others are held at same time to set hours and minutes of each cube.

My buttons are registering serial numbers except for button one which is reading high all the time.

The alarm is not seting on the matrix or in serial monitor HELPHELPHELP!

any input is much appreciated. I know this is in other threads but trust me i've searched high and low and cannot find anything that helps.

here is my code:

please view in attachment : too long

alarm clock code.txt (40.6 KB)

drisa632:
Hi guys,

this is my first post to the forum. I'm a Parsons student in NYC and am in desperate need of help for a final project of mine that is due tomorrow.

I remember getting paid some half decently to produce programs "by tomorrow" but I'll try to help or at least get you help. I'm looking around and I can't find whatever hardware you are using so how can I help you, Mrs. Johnson!? :wink:

drisa632:
My buttons are registering serial numbers except for button one which is reading high all the time.

You are using (button1 == HIGH) when you probably intended to use (button1Val == HIGH). I don't know what you intend with digtalWrite(button1, HIGH); since 'button1' is an INPUT pin, not an OUTPUT.

What kind of text file is that, utf-16 ?
How can we check your code, if we don't have the schematics for the buttons ?

Good eye John! Besides, I didn't find where setAlarm() is called except for inside setAlarm(). How do you intend for this code to work?

im using arduino uno, dcs1307 real time clock. my buttons are digital and look like this schematic in the basic tut.

the set alarm fuction is what i'm having trouble with.

drisa632:
the set alarm fuction is what i'm having trouble with.

I see that function getting called by itself. Can you explain how the recursion works? Also you commented out two calls to setalarm in setup and look. Where do you intend to call this function?

I'm not sure. My prof gave me some half a** 10 sec. explanation of how I should do it. How would you guys do this?

again. I'm trying to set up an alarm function using five buttons. one to set the mode and the other four to set each cube(hours1,hours2,minutes1,minutes2)

thanks for all the input guys

John, I state in the code that buttonVal1 = button1 ....

drisa632:
John, I state in the code that buttonVal1 = button1 ....

That's not helping. You are using button1. Button1 should contain the value of button1val instead. But you defined button1 as constant to store pin number of the buttons. You mixed up. Change button1 to button1Val. You want the value (aka status) of button1 not which pin button 1 is connected to.

drisa632:
I'm not sure. My prof gave me some half a** 10 sec. explanation of how I should do it. How would you guys do this?

again. I'm trying to set up an alarm function using five buttons. one to set the mode and the other four to set each cube(hours1,hours2,minutes1,minutes2)

thanks for all the input guys

A function calling itself is recursion. You can solve some hard problems with recursion but setting alarm clock is not one of the hard problems.

I will give you a starting point and you can follow on. It's your own homework.

First, sense all buttons (you did already)
Second, decide what to do with a flow chart. Say first decide if mode is pressed, no-> do nothing, yes-> check other buttons.
For yes, then check if hour1 is pressed, yes->increment hour1, no-> check if minute1 is pressed.
You fill up the rest of the flow chart, then program according to the flow chart. For any program you want to write, you are better off planning (flow chart) then executing (write code). You did it backwards. Now I'm left to see a broken program and not sure what it is SUPPOSED to do.

thank you so much! I'll post an update soon, i'm not asking anyone to do it for me, just a little guidance
:slight_smile:

I'm gettin a constant "on" for button 1.

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

int hours1;
int hours2;
int minutes1;
int minutes2;

const int button1= 1; //mode
const int button2= 2; //hours
const int button3= 3; //mins
const int button4= 4; //alarmoff
const int button5= 5; //alarmoff

Adafruit_8x8matrix matrix1 = Adafruit_8x8matrix();
Adafruit_8x8matrix matrix2 = Adafruit_8x8matrix();
Adafruit_8x8matrix matrix3 = Adafruit_8x8matrix();
Adafruit_8x8matrix matrix4 = Adafruit_8x8matrix();

int button1Val; //mode
int button2Val; //hours
int button3Val; //mins
int button4Val; //alarm off

int buttonState = 0; // variable for reading the pushbutton status
int alarmHour;
int alarmMinute;
//int newHour1=0;
//int newHour2=0;
//int newMin2=0;
//int newMin1=0;

RTC_DS1307 RTC;

void setup() {
Serial.begin(9600);
Serial.println("Double 8x8 LED Matrix Test");

// if (button1 == HIGH) {
// digitalWrite(button1,HIGH);
// setAlarm();
// }
// else {
// digitalWrite(button1, LOW);
// printTIME();
//}
//
// if (button2 == HIGH){
// digitalWrite(button2,HIGH);
// hours1 = alarmHour/10+1;
// }
// if (digitalRead(button2) == LOW) {
// printTIME();
//// hours1=alarmHour/10+1;
// }
// else {

// hours1=alarmHour/10;
//
// }

// pinMode(button1,OUTPUT);
// pinMode(button2,OUTPUT);
// pinMode(button3,OUTPUT);Is this wrong? I feel like I'm not doing the inputs and out puts right
// pinMode(button4,OUTPUT);
// pinMode(button1,OUTPUT);

Wire.begin();
RTC.begin();

matrix1.begin(0x71); // pass in the address
matrix2.begin(0x70); // pass in the address
matrix3.begin(0x72); // pass in the address
matrix4.begin(0x73); // pass in the address

// matrix1= (now.hour/10);
// matrix2= new.hour- (matrix1 x 10);
// matrix3= now.minute/10;
// matrix4= new.minute - (matrix4 x 10);

pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);Is this completely wrong?
pinMode(button4, INPUT);
pinMode(button5, INPUT);

pinMode(hours1,OUTPUT);

Could you guys maybe help me review my setup code ? just to make sure all this is right

Setting pin mode to inputs for buttons is right. Setting pin mode to outputs for buttons is wrong. Remove them. Buttons are input devices.

Setting pinmode woth hour1 is wrong. Remove that line.

ok, so here is me calling out button1 is pressed for set alarm function.

I think this while loop is where i am going wrong

void setAlarm(){

while(digitalRead(button1)==HIGH){

hours1 = alarmHour/10;
hours2 = alarmHour-hours110;
minutes1 = alarmMinute/10;
minutes2 = alarmMinute-minutes1
10;

Serial.println(hours1);
Serial.println(hours2);
Serial.println(minutes1);
Serial.println(minutes2);

printTIME(hours1);

}

is this right?

Take away the "While" and change it to "if" and see if that works.

Help me here, when a button is pressed, is it HIGH or LOW? It depends on how you hook up the buttons. You never said it. Assume it is LOW, then your code runs when button1 is not pressed, to display hour. I think it will work. Just add the print minute part for completeness. The delay (500) will make your buttons not so responsive but let's worry about getting the program working first.

BTW, if alarm is triggered, do you need to do anything?

I'm not sure. My prof gave me some half a** 10 sec. explanation of how I should do it. How would you guys do this?

You don't suppose that had anything to do with you only half-assed listening, do you?

I was helping until he disappeared maybe time runs out. I wonder where the OP has been a few days before the last day of project.

I wonder where the OP has been a few days before the last day of project.

Probably not working on it. Why should he? We will.

At least, I will until I see crap like that badmouthing the instructor. Then, the poster is on his/her own.