Assistance on Arduino Project

I am working on an Arduino that has a button sequence that triggers a lock. However, I also have the Arduino connected via Ethernet shield. I have it so that I can trigger/reset or see the status of the button sequence through a webserver.

I am having a few problems

  1. I am only sometimes able to see the web server after upload. I believe it has to do with me having poorly written code and using a uno.

  2. I am having problems with the showing the status on my webserver. I had to use bitread with port manipulation since Digital read used to much memory on my arduino.

Any help at all is appreciated

I cannot address your two points directly other than to tell you that your logic using the bitRead() macros are just returning true or false depending upon the physical address of PORTx (not the 8 bit value read at PORTx) then AND’ed with the bit number. FWIW, any bit number higher than seven is invalid for an eight bit device, just sayin’.

That entire if-else logic section needs digitalRead() used rather than bitRead() in order to function. When you use the correct digitalRead() function, how large is the compiled image?

I would need to use a mega board. it goes over the dynamic memory

// What pins are those buttons connected to?
const byte inputPins[numInputs] = {2, 3, 5, 6, 7, 8, 9, 10, 11};

// This pin will be driven LOW to release a lock when puzzle is solved
const byte RELAY_PIN = 12;

Problem: The Ethernet Shield uses pins 10, 11, and 13 (and 12).

I fixed the issue with the pins however when i load by staus webpage and refresh it it fails. It loads once then if i refresh it fails

Besides the errors already pointed out, your lastInputState array has only 1 element, but you try to access 9 elements. It should be declared as lastInputState[numInputs].

You also do not need to be resetting the pins as input/output etc. whenever you reset the game. Do this once in setup() and you are done.

You can also refactor your code a lot as well as use the F() macro everywhere you have constant strings. The attached refactored code only uses ~32% of memory. There may still be logic errors, but it will get you going…

Also note the different pins assigned for the buttons. You will have to adjust your wiring to match (NOTE: you can use the analog pins for digital I/O)

You should also avoid the use of the String class or eventually, your app will crash.

code to big to include so it is attached.

code.ino (8.33 KB)

Thank you so much, Im still getting the hang of Arduino so appreciate all the assistance

DO you know why when the button is being pressed the checkboxes and the names just disappear