Show Posts
Pages: [1] 2
1  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: Today at 05:04:38 pm
Changing the write_block with update_block results in this error :


_1.ino: In function 'void loop()':
_1:36: error: 'eeprom_update_block' was not declared in this scope


2  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: Today at 03:27:40 pm
I meant to say statement - not function.

About the switch transition problem - I'll try to fix it and let you know.

Thank you very much for your help.
3  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: Today at 03:12:56 pm
I don't know - whatever works best, but it's best to write when the switch becomes pressed (or unpressed), not all the time it is pressed.

You mean to have both buttonState - HIGH and LOW statements?

Also, best to do a read of the EEPROM first then compare with what you're about to write so you don't write the same value, and limit the life of your EEPROM.

In the buttonState function I tried putting the read instead of write block and it just outputs the first number I entered. Does this solve my issue with only one value to be written in the eeprom?
4  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: Today at 02:58:34 pm
Well that's without a doubt one of the worst mistakes I could make, really slipped out.

It works now.

But to store five values in five different variables, it's mapped values actually, for example the first variable i store 137, second 267, third 600 and so on, but only write the value once, how can i do this.

Can this be made using one button and using a for loop, or do I need to have 5 buttons?

Thanks.
5  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: Today at 02:21:22 pm
I'm still stuck with this.

In case I'm not clear, as you can see I have a potentiometer on pin A0, button on pin 2, and when I press the button I need to save the potentiometer value in EEPROM memory under name VALUE1 for ex, then when I press another button again save the potentiometer value in eeprom memory under name VALUE2 and so on, and then read those saved values in serial window.

So far, with this code that I have nothing is showing up.

So this is what I have so far, anyone able to help me out ?

Code:
#include <avr/eeprom.h>
 
const int buttonPin = 2;
 
int buttonState = 0;
 
struct settings_t
{
  long alarm;
  int mode;
} settings;
 
void setup()
{
  pinMode(buttonPin, INPUT);
  eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
    // ...
}
void loop()
{
   
    buttonState = digitalRead(buttonPin); 
 
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...
    settings.mode = analogRead(A0);  // potentiometer on A0
    // if they push the "Save" button, save their configuration
    if (buttonState == HIGH)  // button attached on digital pin 2
    {
      eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
      eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
      Serial.println(settings.mode);
    }
}
6  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: July 28, 2014, 02:01:19 pm
This involves a char variable, while I need only int variable, I see you take the lenght of the string, but how can I modify this for my purpose, with potentiometer?

More specifically

int mappedValue[] = { 1, 2, 3, 4, 5 };
int sensorVal[]  = { A, B, C, D, E};

when A will be a value from the potentiometer when button 1 is pressed. Then value B also reads value from potentiometer when button 2 is pressed and so on.

This is saved in eeprom memory and later read.
7  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: July 26, 2014, 07:42:01 am
And then how do I read the saved values? I ran the program and the board rx button wasn't blinking so I'm thinking maybe it didn't save anything.

Here's the code again :

Code:
#include <avr/eeprom.h>

struct settings_t
{
  long alarm;
  int mode;
} settings;

void setup()
{
  eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
    // ...
}
void loop()
{
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...
    settings.mode = analogRead(A0);  // potentiometer on A0
    // if they push the "Save" button, save their configuration
    if (digitalRead(2) == HIGH)  // button attached on digital pin 2
      eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
}

EDIT : I thought maybe because I didn't declare the button it may have been causing problems but no, still doesn't do anything.

Code:
#include <avr/eeprom.h>

const int buttonPin = 2;

int buttonState = 0;

struct settings_t
{
  long alarm;
  int mode;
} settings;

void setup()
{
  eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
    // ...
}
void loop()
{
   
    buttonState = digitalRead(buttonPin); 
 
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...
    settings.mode = analogRead(A0);  // potentiometer on A0
    // if they push the "Save" button, save their configuration
    if (buttonState == HIGH)  // button attached on digital pin 2
      eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
}
8  Using Arduino / Project Guidance / Re: Arduino multivalue problem on: July 23, 2014, 09:47:59 am
Thanks for the links - I did read them and came across this code.

Code:
#include <avr/eeprom.h>

struct settings_t
{
  long alarm;
  int mode;
} settings;

void setup()
{
  eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
    // ...
}
void loop()
{
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...

    // if they push the "Save" button, save their configuration
    if (digitalRead(13) == HIGH)
      eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
}

 But I really don't understand what's going on in here?

How can I manipulate for ex. the int mode variable to show me the value of the potentiometer?

mode = analogRead(A0)?

Thanks for the help.
9  Using Arduino / Project Guidance / Arduino multivalue problem on: July 23, 2014, 06:39:21 am
Hi guys,

I have a problem - I don't know how to save certain values. The best example would be the radio. You're searching for stations and when you find one - for ex. 95.5 you save the value 95.5 in EEPROM under the name RADIO1, then 98.2 under RADIO2 and so forth - in the EEPROM.

For this I need it with a potentiometer for start, and then I'll modify it.

Any suggestions? Thanks a lot!
10  Using Arduino / Programming Questions / DS18B20 Adress on: December 18, 2013, 02:16:15 pm
Hi guys,

I have a DS18B20 sensor, and in my program I have the sensor's adress. I want to use this as an advantage.

How can I write when the given adress doesn't match (cause there is only one same adress) ie the sensor is off the board, terminate the whole program.

I have something like this:

DeviceAddress insideThermometer = { 0x28, 0xA0, 0xD7, 0x1A, 0x05, 0x00, 0x00, 0x5B };

So I don't know how to say like if the adress in the { ... } is not the same with the one on the board, terminate the program, shut the LCD etc.?

Thanks in advance!
11  Using Arduino / Programming Questions / Arduino protection on: November 27, 2013, 04:15:36 pm
Hi friends,

I have a project which involves a DS18B20 sensor. I know it has a certain "adress" which can be recognized by the arduino.

I want to use this as protection. For example, how can I make when the DS18B20 is not on the board with the very specific adress ( which means only one sensor to be right for the board, never another one) and when it's not on the screen shuts off. Possibly 7 segment display shuts off.

Thank you and all the best.
12  Using Arduino / Programming Questions / Re: Mapping values on: November 24, 2013, 07:16:38 am
Thank you for the reply I will try this.
13  Using Arduino / Programming Questions / Re: Mapping values on: November 23, 2013, 05:32:11 am
Thank you all for the replies and sorry for the late response.

I did find something that suits me well, but I do need it with a little bit of upgrade.

http://www.kasperkamperman.com/blog/arduino/arduino-programming-map-and-smooth/

The constrain example at the end is good for minimum and maximum value, but I need 2 more values between min and max.(http://interface.khm.de/index.php/lab/experiments/nonlinear-mapping/) This is a link that has a good example that can be used but I don't know how to achieve this.

If anyone can succeed to make it for me I'd be very grateful.

Thank you all again.
14  Using Arduino / Programming Questions / Mapping values on: November 21, 2013, 12:41:38 pm
Hi,

I have a question about Arduino's mapping option.

As described in the link : http://arduino.cc/en/Reference/Map

I want the starting and ending point of the potentiometer not the be min and max, but I want to set the minimum and maximum values myself. For example, 15% of value to be 0, and maximum to be for example on 79% to be 10. After that, 5 should be manually - by me - for example I want 5 to be 60%.

I want the scale or the map, to be divided manually - for me to set the values.

I hope you understood me.
15  Using Arduino / Programming Questions / Re: LED dimming on: June 08, 2013, 03:12:41 pm
How could I've not thought of that.

I knew that it was going too fast, I just didn't try adding a delay in the for loop. That wraps it up.

Thank you for your help.
Pages: [1] 2