Atari400:
val is supposed to mean "value of" as in basic language.
as you have noticed this is not BASIC
Try using
x = seq[sayac] & 0xf;
If you want to recover the individual value of one digit from a string of digits.
However this is very wasteful as you are using 8 bytes to hold what is just a one byte number.
As PaulS points out, there is no "standard library" function named val(), so you must write your own. While I'm not sure what you're trying to do, given the name of the missing function, it appears that you are trying to store the individual values in the seq1 array in EEPROM. If that's the case, look at the following:
// this routine writes parameter values into eeporom
#include <EEPROM.h>
char *seq1 = "0000001100101110";
int sayac;
int x;
void setup()
{
Serial.begin(9600);
for (sayac = 0; sayac < 15; sayac += 1)
{
x = val(seq1, sayac);
Serial.print("x = ");
Serial.println(x);
//EEPROM.write(sayac, x);
}
}
void loop()
{
}
/*****
Function that returns a byte value for a character passed to it.
Parameters:
char *array A pointer to the character array
int index The element in the array of interest
Return value:
byte
*****?
byte val(char *array, int index)
{
byte b;
b = (byte) *(array + index) - '0';
return b;
}
When the function val() is called, you pass to it the starting address of the seq1 array of characters. Because it is an array, you could make the first line of the function as shown, or as you could write the function as:
The code performs the same because of the way pointers work relative to array data definitions. The expression "- '0'" at the end of the one statement converts the byte character being read from the array into an integral value. The character zero ('0') has an ASCII value of 48. If you didn't make the adjustment, you'd get:
b = (byte) array[index];
b = (byte) array[0];
b = (byte) 48;
b = 48;
which makes the value 48. Since I'm assuming val() should return an integral value, not a character value, I subtracted '0' from each numeric character read in the for loop:
b = (byte) array[index] - '0';
b = (byte) array[0] - 48;
b = (byte) 48 - 48;
b = 0;