Pages: 1 2 [3]   Go Down
Author Topic: Arduino doesn't do what I've written in the code (FIXED).  (Read 1798 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After looking for something strange in the code and seeing that I'm not able to find anything strange and testing different methods to save pin values in a byte and saving this byte to the EEPROM in the last three days.......I'll let this project stopped till the moment I've more knowledge about Arduino, by now I'll do this project in the "simply" way, I will store the presets for the outputs in the code itself, the problem is that if i want to change any of the presets I have to do it reprogramming again the Arduino. I hope that my learning curve makes me try to finish this project like it was originally in my mind soon.
Thanks all for your help.
Logged

Offline Offline
Newbie
*
Karma: 4
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Conguito,

Quote
After looking for something strange in the code and seeing that I'm not able to find anything strange and testing different methods to save pin values in a byte and saving this byte to the EEPROM in the last three days

You'll have to elaborate a little more on what you tested and where the problem is.  Is the problem reading the port states and writing the data bits to byte "valores"?  That part of your code looks ok to me and think it should work as is.  Have you tested reading the EEPROM to see if "valores" is being written to the correct location?  You can write a simple seperate sketch to check the values that have been stored in the EEPROM.

While  you are in the developing stage its helpful while debugging to enable serial communication and at points in the program print out program state information data which will be displayed in the Arduino IDE's serial monitor window.  For example:
Code:
Serial.begin(9600); // add this in your setup()

Serial.println(valores, BIN); // add this in your code right after fully populating valores with all the bits.



 
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well.....the problem is that the pins that use the serial port are in use as output pins, but I've had another idea, I have here arround and will use an atmega1284p with the same sketch and use the second serial port to see what is happening.........maybe the error isn't where I have been looking, so I will try with a larger microcontroller to have a serial monitor to look while the arduino is running, so it will be easier to find out where is the problem.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I post to tell you all that I finally got it to work, it was an error in the code. I forgot to put an EEPROM.read instruction in a function, so Arduino was never able to read from the EEPROM. Now it's all working fine. The serial monitor was a big help, finally I used the code with an atmega1284p mounted like a sanguino board to be able to use the serial monitor and I find out the error very soon.
I want to thank you all for your help, if someone is interested I can paste here the code. First I have to optimize it, but I think that in two days I will have it finished.
Logged

Offline Offline
Newbie
*
Karma: 4
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Conguito,

Glad to hear you got it working.

Logged

Pages: 1 2 [3]   Go Up
Jump to: