arduino manager

just started using Arduino manager and the code generator.The code is directly from the code generator I am trying to read a input value from pin a4 its been a long time since I played with Arduino so I am a bit lost can anyone help me please

thanks

Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch_aug10a:28: error: conflicting declaration 'float A4'

float A4;

^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:249:0,

from sketch\sketch_aug10a.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega/pins_arduino.h:72:22: note: previous declaration as 'const uint8_t A4'

static const uint8_t A4 = PIN_A4;

^

C:\Users\barrd\Documents\Arduino\bluetooth\sketch_aug10a\sketch_aug10a.ino: In function 'void processOutgoingMessages()':

C:\Users\barrd\Documents\Arduino\bluetooth\sketch_aug10a\sketch_aug10a.ino:118:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

iosController.writeMessage("A4",A4);

^

C:\Users\barrd\Documents\Arduino\bluetooth\sketch_aug10a\sketch_aug10a.ino: In function 'void switchPin2SyncCallback()':

C:\Users\barrd\Documents\Arduino\bluetooth\sketch_aug10a\sketch_aug10a.ino:136:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

iosController.writeMessage("Pin2",digitalRead(Pin2_PIN));

^

exit status 1
conflicting declaration 'float A4'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

/**
 * This file has been generated with Arduino Manager for iPhone/iPad version: 10.1
 *
 * https://itunes.apple.com/it/app/arduino-manager/id497240094?l=en&mt=8
 *
 * For more information write to fabboco@gmail.com
 **/
#include <RBL_nRF8001.h>
#include <SPI.h>
#include <boards.h>
#include <IOSControllerBLE.h>

#define Pin2_PIN      2

/* Start your code (defines) */
/* End your code */

/*
 *
 * IOSController Library initialization
 *
 */

IOSControllerBLE iosController(&doWork,&doSync,&processIncomingMessages,&processOutgoingMessages,NULL,NULL);

/******* Start Global Variable for Widgets *******/

float A4;


/******* End Global Variable for Widgets *******/

void setup()
{  
  ble_begin();
  
  Serial.begin(115200);

  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  pinMode(10,OUTPUT);
  digitalWrite(10,LOW);

  pinMode(Pin2_PIN,OUTPUT);
  digitalWrite(Pin2_PIN,LOW);


  /* Start your code (setup) */
  /* End your code */
}

void loop() {  
  
  iosController.loop();
}

/**
*
*
* This function is called periodically and it is equivalent to the standard loop() function
*
*/
void doWork() {
  


  /* Start your code (doWork) */
  /* End your code */
}

/**
*
*
* This function is called when the ios device connects and needs to initialize the position of switches and knobs
*
*/
void doSync (char *variable) {


  if(strcmp(variable,"Pin2")==0) {

    switchPin2SyncCallback();
  }


  /* Start your code (doSync) */
  /* End your code */
}

/**
*
*
* This function is called when a new message is received from the iOS device
*
*/
void processIncomingMessages(char *variable, char *value) {


  if(strcmp(variable,"Pin2")==0) {

    switchPin2Callback(atoi(value));
  }


  /* Start your code (processIncomingMessages) */
  /* End your code */
}

/**
*
*
* This function is called periodically and messages can be sent to the iOS device
*
*/
void processOutgoingMessages() {


  iosController.writeMessage("A4",A4);


  /* Start your code (processOutgoingMessages) */
  /* End your code */
}


/* Widgets synchronization callbacks */

void switchPin2SyncCallback() {

  /* Start your code (switchPin2SyncCallback) */

  //iosController.writeMessage("Pin2",Insert value here);

  /* End your code */

  iosController.writeMessage("Pin2",digitalRead(Pin2_PIN));
}


/* Widgets operations callbacks */

void switchPin2Callback(boolean on) {

  /* Start your code (switchPin2Callback) */
  /* End your code */

  digitalWrite(Pin2_PIN,on);
}



/* Analog input preprocess functions */



/**** User Functions *****/

/* Start your code (User Functions) */
/* End your code */

A4 is already defined one of the Mega2560 analogue input pins. Change your variable name to something else.
float A4; // redefines that name as a 'float' variable. You don't want to do that.

Instead:-const byte inPin = A4;then

int iVal = analogRead(inPin);
// or
bool bVal = digitalRead(inPin);

thank you

maddave:
thank you

No worries. And I just edited and added a little more info. :slight_smile: