Show Posts
Pages: [1] 2 3 4
1  Topics / Robotics / Re: Can the Arduino save values in the EEPROM memory when they are generated? on: April 15, 2014, 04:51:07 pm
I do see the inconsistency on my knowledge. I have a lot to learn of course!!! I just wanted to point out that I had done a few simple Arduino projects in the past.

As I said before, thanks to you and CrossRoads now I know the basics about Arduino memories and how to interact with them. So I know your are not getting at but giving me good advise instead.

At the moment I have enough to start playing a bit with some code and keep on learning how to program correctly. Sure enough I will keep coming back to the forum for the great support.

Thanks!!!





2  Topics / Robotics / Re: Can the Arduino save values in the EEPROM memory when they are generated? on: April 15, 2014, 01:16:48 pm
Thanks for answering my questions.

Grumpy_Mike I agree with you in the fact that I am not an expert. However, I don´t consider myself a beginer either. I  build my own robots with Arduino and know how to make them avoid obstacules or follow lines,  interact with leds, how to drive them with infrared or radio signals, interact with visual programs like Scratch and some other things as well. So I did the "Hello World" of Arduino by lighting the led 13 and other tutorials a long time ago. All the codes I have written or adapted are available of course to prove what I´m saying.

I am sorry that You think that I ask "the most trivial questions". I haven´t got experience handling EEPROM memory as I mentioned. Regarding where to put the if statemen, I always put them on the loop part of the program. However, a few days ago you told me not to write in the EEPROM memory on a loop as I could damage the memory. Before that I always did this kind of things in SRAM memory also on a loop. So even if this was for reading values not writting, I just wanted to be sure that this if statement went as I thought on the loop part.
3  Topics / Robotics / Re: Can the Arduino save values in the EEPROM memory when they are generated? on: April 15, 2014, 06:26:09 am
The example code is very useful CrossRoads. However, I have a few question about it. Suppose that I'm doing a test for 255 (0xFF), which is the value read back if EEPROM hasn't been written to yet . Why then in the code you sent me shall I store data after the if statement? Why I have to put EEPROM.write (0,21) if I am just trying to know what values were already stored? And yet another question please: that if statement should go In the setup or in the loop?

I tried other retrieving code that I have used before, but now in an Arduino where I have never written anything in the EEPROM before:
Code:
#include <EEPROM.h>
void setup(){
Serial.begin(9600);
}
void loop(){
byte x;
for(int i=0; i<3; i++){
x = EEPROM.read(i);
Serial.println(x);
}
delay(800);
}
On serial monitor the values shown where like this:
105
255
255
105
255
255
......
......
Is the above the 255 (0xFF) message? If it´s not, why I don´t get it as I should?

Thanks your for all the help given so far.
4  Topics / Robotics / Re: Can the Arduino save values in the EEPROM memory when they are generated? on: April 14, 2014, 06:04:03 pm
I understand now that it´s possible to write in EEPROM from the loop but only when data needs to be written.

Regarding the way to test values, if you can give me an example it would help me a lot. I just don´t figure out the way to do it myself.





5  Topics / Robotics / Re: Can the Arduino save values in the EEPROM memory when they are generated? on: April 14, 2014, 03:26:24 pm
I have overwritten EEPROM data while trying that code. Is there a problem or risk for memory if I do so?

There is no way to erase all I have written in EEPROM to start from scratch?

Sorry CrossRoads but I don´t know how to do the test for 255 (0xFF). Can you tell me to do it please?

If I am not wrong you should never try to writte in EEPROM from loop as it would damage the memory. So it looks like a dead end for my project. Sure enough you know something that I don´t so it can be done. ¡Help please to understand this!

Sorry for so many things at once.





6  Topics / Robotics / Re: Can the Arduino save values in the EEPROM memory when they are generated? on: April 14, 2014, 02:43:33 pm
Thank you CrossRoads for the very useful link. I coudn´t find the 8.4 EEPROM Data Memory topic though. I found Memory Types on page 61 instead.

Please Grumpy_Mike and Cross Roads, tell me if the following reasoning is correct. Look at this code:

Code:
#include <EEPROM.h>   
void setup(){
EEPROM.write(0, 20);  //
EEPROM.write(1, 21);
EEPROM.write(2, 22);
}
void loop(){
//code for line follower maze solver in here
}

Let´s supose that in the loop I put the code for a line follower maze solver. At the end of the maze an array has all the right turns in it ( as the wrong turns had been eliminated ).  So lets say that the code I uploaded for the robot to solve the maze tells the Arduino that when the array with the right turns is completed the program has to go back to void setup and save those values in the EEPROM memory with EEPROM.write. Is this the right way to write in EEPROM memory while the sketch is running?

Thanks to you both.
7  Topics / Robotics / Can a sketch write to EEPROM while it is running.? on: April 14, 2014, 01:03:18 pm
Hi there,

I know now thanks to the help I was given in this forum that I can upload values to the EEPROM memory and then retrieve them by uploading another code. However, I would like to know if there is a way to store in the EEPROM memory in real time when the array values are generated.

What I am trying to do is a line follower maze solver. I would like for the robot to save the correct turns in an array directly to the EEPROM memory, so when the robot has finally solved the maze the correct turns remain stored even if the robots is switched off.

Any help or ideas are more than welcome.

8  Topics / Robotics / Re: Help please with arrays. on: April 13, 2014, 10:01:38 am
I didn´t expect yersterday when I wrote the post that I would learn so many things in one day.

Now it´s time to put it all in practice.

¡Thank you so much Grumpy_Mike for all the help!!!
9  Topics / Robotics / Re: Help please with arrays. on: April 12, 2014, 05:45:08 pm
Thanks again.

I uploaded the code to store the values in frash memory:

Code:
void setup(){
Serial.begin(9600);
}
void loop(){
const prog_uchar PROGMEM bankLSB[] = { 0, 16, 25, 43, 96 };
}

Then I tried to retrieve a value using this code below:

Code:
int x =pgm_read_byte_near

void setup(){
Serial.begin(9600);
}
void loop(){
x = pgm_read_byte_near(&bankLSB[0])
Seriel.println(x);
delay(800);
}

When I try to upload the code I get the error "expected constructor, destructor or type conversion before void"
I think the problem may be the int x =pgm_read_byte_near sentence, but I don´t know how should I declare the variable in this case.

So all in all, it seems that I can store the values in PROGMEM with the first code shown but the code to retrieve and print in serial monitor one of the values has something wroing in it.

Can you tell me please what am I doing wrong now? Thanks for the patience Grumpy_Mike!

10  Topics / Robotics / Re: Help please with arrays. on: April 12, 2014, 03:39:35 pm
You were right. There was some kind of problem with Serial Monitor. I restarted the PC and now both codes work perfectly.

So the original quest is sorted thanks to your help Grumpy_Mike. Now I know how to use a simple array and how the values are stored in the SRAM memory.

To go a little bit further, can you tell me please what should I change in the code we where working with to save the mySensVals[0] = 10 in the flash memory and retreive it from it when I restart the Arduino? I know I should use PROGMEN but all I have seen use sample codes far too complicated for me to understand.

11  Topics / Robotics / Re: Help please with arrays. on: April 12, 2014, 01:19:26 pm
I know I am being a pain in the neck. But I still can´t get it working.

When I upload this code I don´t get any print on serial monitor:

Code:
int mySensVals[5] = {2, 4, -8, 3, 2};

void setup(){
Serial.begin(9600);
mySensVals[0] = 10;
}
void loop(){
mySensVals[0];
Serial.println (mySensVals[0]);
delay(800);
}

On the other hand, when I upload the other code:

Code:
int mySensVals[6] = {2, 4, -8, 3, 2};

void setup(){
Serial.begin(9600);
mySensVals[0] = 10;
}
void loop(){
x = mySensVals[0];
Serial.println(x);
delay(800);
}

I get the error "x" was not declared in this scope

Is there anything else that I am still missing? Thanks.
12  Topics / Robotics / Re: Help please with arrays. on: April 12, 2014, 12:51:24 pm
With your help Grumpy_Mike I´m getting much closer to finally understand arrays.

Let me ask you one more thing please. I am trying to make a code where I replace the value 2 by 10 and then serial monitor shows the number 10.

I know that some of the instructions should be like the following below:

int mySensVals[6] = {2, 4, -8, 3, 2};

mySensVals[0] = 10;

Serial.println x = mySensVals[0];

However I don´know how to structure the instructions in a code correctly to get the task done. I have tried many variations on the code and always get errors as I don´t know well what should I put in void setup and void loop.

Can you please show my how to make this very first code with arrays? Thanks!



13  Topics / Robotics / Re: Help please with arrays. on: April 12, 2014, 08:55:02 am
Very helpful Grumpy_Mike. It helps me to understand a better way arrays and its possibilities.

However, to know if i understand the basics well please tell me if this more basic approach is also right.

This is my array:

int mySensVals[6] = {2, 4, -8, 3, 2};

I can assing a new value to my array, so for example now the value 2 is replaced by the value 10:

mySensVals[0] = 10;

Is this value stored in the SRAM or fhe Flash memory of the Arduino? I think it´s stored in the SRAM memory buy please let me know if I am right.

Now to retrieve a value from my array:

x = mySensVals[4];

In this case the value that I will retrieve would be the number 3.

Please tell me if my reasoning is right o wrong. Thanks!
14  Topics / Robotics / Help please with arrays. on: April 12, 2014, 07:06:46 am
Hi everyone,

i´m trying to get the handle on arrays. Basically what I want to know is if there is a way to storage the arrays values in the Arduino. I heard that you can do so in the EEPROM or the SRAM memories. However, if that´s the case, I don´t know how to do so.

The other question is if I can use arrays to program for example a line maze solver.

Any simple code on the subjet of arrays and ways to storage values on Arduino would be very helpful.

Thanks!



15  Topics / Robotics / Help please with IR remote control. on: October 06, 2013, 04:58:47 pm
Hi,

I need help please with the IR remote control routine. So far I can get the key values from only one IR remote control. However, when I tried with a universal remote control and many others and I can't get any values from all those.

The IR receiver is attached to Arduino's pin 12. This is the code I am using:

Code:
#include <IRremote.h>
int device = 0;
int command = 0;

int RECV_PIN = 12;   //set to pin connected to IR decoder

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
 
  if(getIR()) {
    Serial.print("device number  ");
    Serial.println(device);
    Serial.print("key code   ");
    Serial.println(command);
    Serial.println();
  }
}


boolean getIR() {
  boolean valid = 0;
  if (irrecv.decode(&results)) {   
    device =  results.value >>24;
    command = lowByte(results.value - device);  //evaluates to 147
    irrecv.resume(); // Receive the next value

    if (device == 28) {   // 28 is decimal for 1C of 1C E350AF
      valid = 1;
    }
    else(valid = 0);
  }
  return (valid);
}

I need to make it work with the universal IR remote control. What am I doing wrong?
Pages: [1] 2 3 4