Analogread 255 4 times

Hy there guys ..... i have a question and i think it is programming and i don't know where is it
well i have a sanguino barebone and i wish to sand some data over rf transciver and to have a lcd 16x2 showing what i send
BUT when i read a analog pin with ADC the value is 0 to 255 when get to 255 start over again to 0 four times
0V_ 0-255 0-255 0-255 0-255 _for5v
when i quote this line

analogWrite(ledPin2, emontx.A/4);

the value read is 511

here is the code i use

/*
* 6 INTRARI ANALOGICE
* EMITATOR RFM12B
* LCD
*
*/

 #include <RF12.h>
 #include <JeeLib.h>
 #include <PortsLCD.h> 
 #include <Wire.h>
 #include <avr/wdt.h>     // Include watchdog library                                                   
 LiquidCrystal lcd(23, 22, 21, 20, 19, 18);


 const byte network = 50; // network group (can be in the range 1-255).
 const byte myNodeID = 10; // unique node ID of receiver (1 through 30)
 const byte IDreceptor = 11; // unique node ID of receiver (1 through 30)

 const byte freq = RF12_868MHZ; // Match freq to module
 const byte RF12_NORMAL_SENDWAIT = 0;
 int ledPin = 8;
 int ledPin2 = 14;
 int potA = PA7;
 int potB = PA6;
 int potC = PA5;
 int potD = PA4;
 int potX = PA3;
 int potF = PA0;

typedef struct {
  int A, B, C, D, X, F;} PayloadTX;
 PayloadTX emontx; 

void setup()
	{
        wdt_enable(WDTO_4S); // Enable watchdog: max 4 seconds
	rf12_initialize(myNodeID, freq, network); // Initialize RFM12
	pinMode(ledPin, OUTPUT);
	pinMode(ledPin2, OUTPUT);
	//pinMode(potA, INPUT);
        //pinMode(potB, INPUT);
	//pinMode(potC, INPUT);
	//pinMode(potD, INPUT);
	//pinMode(potX, INPUT);
	//pinMode(potF, INPUT);  
	lcd.begin(16, 2);
	}

 void loop()
	{
	lcd.clear();
emontx.A = analogRead(potA);
emontx.B = analogRead(potB);
emontx.C = analogRead(potC);
emontx.D = analogRead(potD);
emontx.X = analogRead(potX);
emontx.F = analogRead(potF);
        afisareLCD();
	analogWrite(ledPin2, emontx.A/4);

        int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}
	rf12_sendStart(IDreceptor, &emontx, sizeof emontx);
	digitalWrite(ledPin, HIGH);
	delay(20);
	digitalWrite(ledPin, LOW);
        wdt_reset();    // Reset watchdog
	rf12_sendWait(RF12_NORMAL_SENDWAIT); // wait for send completion
	}

     void afisareLCD (void)
  {
    	lcd.setCursor(0,0); //primul rand  
	lcd.print("A"); 
	lcd.print(emontx.A);  
 	lcd.setCursor(5,0); //primul rand  
	lcd.print("B"); 
	lcd.print(emontx.B);
	lcd.setCursor(10,0); //primul rand  
	lcd.print("C"); 
	lcd.print(emontx.C); 
	lcd.setCursor(0,1); //primul rand  
	lcd.print("D"); 
	lcd.print(emontx.D); 
	lcd.setCursor(5,1); //primul rand  
	lcd.print("X"); 
	lcd.print(emontx.X); 
	lcd.setCursor(10,1); //primul rand  
	lcd.print("F"); 
	lcd.print(emontx.F); 

	//lcd.setCursor(0,1); //al doilea rand  
	//lcd.print("TX-"); 
	//lcd.print(sizeof emontx);  
        //lcd.print(emontx[i]); 
  }

Where do u think my problems comes

int potX = PA3; i tried = A3, =3

if i use other pin that i know it returns 1023 .... it returns 255 that's why i think is a software bug

if i use other pin that i know it returns 1024

If an analogRead returns 1024 on a standard AVR, you've got real problems.

int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}

A simple "for" loop might be easier to read.

what do u mean i got problems if returns 1024
first potX was potE pot2E same thing
after that when i define other pin for int potX = A3, A0....A7; i get 255
for other variables on the same pins i get 1023
the variable that reads .... or the one
i don't know how i should use that for... i use that struct and i don't know that works too
and

int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}

this sketch was a simple analog send example .. and i modified it
that line was the heart of the example

i had tried this sketch same result

/*
* 6 INTRARI ANALOGICE
* EMITATOR RFM12B
* LCD
*
*/

 #include <RF12.h>
 #include <JeeLib.h>
 #include <PortsLCD.h> 
 #include <Wire.h>
 #include <avr/wdt.h>     // Include watchdog library   
 LiquidCrystal lcd(23, 22, 21, 20, 19, 18);
  // Constantele folosite de rf12b:
 const byte IDretea = 50;       // grupul retelei (poate fi intre 1-255).
 const byte IDpropriu = 10;      // codul unic pentru receptor (poate fi intre 1-30)
 const byte IDreceptor = 11; // unique node ID of receiver (1 through 30)
 const byte Frecventa = RF12_868MHZ; // Frecventa modulului


 const byte RF12_NORMAL_SENDWAIT = 0;
 int ledPin = 8;
 int ledPin2 = 14;
 int potA = 0;
 int potB = 1;
 int potC = 2;
 int potD = 3;
 int potE = 4;
 int potF = 5;
 
typedef struct {
  int A, B, C, D, E, F;} PayloadTX;
 PayloadTX payload; 

void setup()
	{
        wdt_enable(WDTO_4S); // Enable watchdog: max 4 seconds
        rf12_initialize(IDpropriu, Frecventa, IDretea); // initializarea modulului RFM12B cu setarile de mai sus
	pinMode(ledPin, OUTPUT);
	pinMode(ledPin2, OUTPUT);
	//pinMode(potA, INPUT);
        //pinMode(potB, INPUT);
	//pinMode(potC, INPUT);
	//pinMode(potD, INPUT);
	//pinMode(potE, INPUT);
	//pinMode(potF, INPUT);
	lcd.begin(16, 2);
	}
 const int payloadCount = 6; // the number of integers in the payload message
 //int payload[payloadCount];
 void loop()
	{
	lcd.clear();
  
	for( int i= 0; i < payloadCount; i++)
		{
payload.A = analogRead(potA);
payload.B = analogRead(potB);
payload.C = analogRead(potC);
payload.D = analogRead(potD);
payload.E = analogRead(potE);
payload.F = analogRead(potF);
     afisareLCD();
		}
	analogWrite(ledPin2, payload.A/4);
	while (!rf12_canSend()) // is the driver ready to send?
	rf12_recvDone(); // no, so service the driver
	//rf12_sendStart(IDreceptor, &payload, payloadCount*sizeof payload); //asta 
        rf12_sendStart(IDreceptor, &payload, payloadCount*sizeof(int));//sau asta
	digitalWrite(ledPin, HIGH);
	delay(20);
	digitalWrite(ledPin, LOW);
        wdt_reset();    // Reset watchdog
	rf12_sendWait(RF12_NORMAL_SENDWAIT); // wait for send completion
	}

    void afisareLCD (void)
  {
lcd.setCursor(0,0); //primul rand  
	lcd.print("A"); 
	lcd.print(payload.A);  
 	lcd.setCursor(5,0); //primul rand  
	lcd.print("B"); 
	lcd.print(payload.B);
	lcd.setCursor(10,0); //primul rand  
	lcd.print("C"); 
	lcd.print(payload.C); 
	lcd.setCursor(0,1); //primul rand  
	lcd.print("D"); 
	lcd.print(payload.D); 
	lcd.setCursor(5,1); //primul rand  
	lcd.print("X"); 
	lcd.print(payload.E); 
	lcd.setCursor(10,1); //primul rand  
	lcd.print("F"); 
	lcd.print(payload.F); 

  }

analogRead never returns 1024. Its range is 0..1023 inclusive.

ye ye ye .... sorry MY BAD MY BAD i get 1023 i will modify my previous posts ...

The argument to analogRead() should be a pin number in the range 0 .. 5.

If you suspect that the return value from analogRead() is wrong, print the actual return value to the serial port for confirmation.

PeterH
sanguino has 0 to 7 analog pins

ATMega644P

+---/---+
(D 0) PB0 1| |40 PA0 (AI 0 / D31)
(D 1) PB1 2| |39 PA1 (AI 1 / D30)
INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
RST 9| |32 AREF
VCC 10| |31 GND
GND 11| |30 AVCC
XTAL2 12| |29 PC7 (D 23)
XTAL1 13| |28 PC6 (D 22)
RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
+--------+

and that's why i use the 16x2 liquid cristal to see what value analogread returns

hunt333r:
sanguino has 0 to 7 analog pins

OK, then the argument to analogRead() needs to be 0 .. 7 on that board. Otherwise my recommendation stands. If you suspect the return value from analogRead() is wrong then print out the return value for confirmation.

 void loop()
	{
	lcd.clear();
  
	for( int i= 0; i < payloadCount; i++)
		{
payload.A = analogRead(potA);
payload.B = analogRead(potB);
payload.C = analogRead(potC);
payload.D = analogRead(potD);
payload.E = analogRead(potE);
payload.F = analogRead(potF);
     afisareLCD();
		}

Better read the style guide:

Oh ThenNick, Gammon, PeterH, MarkT and not the last AWOL THANK YOU ALL for your help ... when i get stuck every time i post here and every time i get some answers ..... and this time too

ok... logic stuff
for me it was curious this
1 every time i changed the variable name or read pin .... 0-255 same thing
2 if i changed the code same thing
3 if i deleted one variable .... everything was ok

i was thinking if the int could not cope with the values and tried to keep it maximum

An int stores a 16-bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).

and i tried to use long int

Long variables are extended size variables for number storage, and store 32 bits (4 bytes), from -2,147,483,648 to 2,147,483,647.

and i changed this part

typedef struct {
long int A, B, C, D, E, F;} PayloadTX; //long  or unsigned long
 PayloadTX emontx;

Now both codes work just fine reading and sanding the data

THANK YOU ALL again !!!!!! And good luck in all your projects .