Help with a code

Hi im 100% new to Arduino and trying to build my first project that I purchased from someone it’s a game
It’s called plasma ball this is the diagram and I fallow it to the " T " but when im trying to install the code its not working. can anyone please help me with it. what it does when u hold both of the plasma ball together it trigger actuator up when u touch it and when u let it go its go down but the problem when I try to upload the code i`m keep getting error messages can someone please help me with it and see why its not letting me upload the code im using the Arduino UNO r4 wifi thank you : (
This is the code –

**
 * Dual Plasma Ball
 * 
 * This sketch is an escape room puzzle in which players must simultaneously place their hands on two plasma balls,
 * in order to make a linear actuator rise up. When a plasma ball is touched, the current through it rises, and this
 * is detected using an IN219 sensor.
 */

// DEFINES
#define DEBUG

// INCLUDES
// Arduino library for I2C connection
#include <Wire.h>
// Current sensor library. See https://github.com/johngineer/ArduinoINA219
#include "src/INA219/INA219.h"
// Since the INA219 reading can be a bit noisy, we'll smooth out values using a running average of a value
#include "src/RunningAverage/RunningAverage.h"

// CONSTANTS
// You can use up to 16 IN219 devices on the same I2C bus, so long as each is assigned a unique
// address as described in the datasheet http://www.ti.com/lit/ds/symlink/ina219.pdf
const byte numSensors = 2;
const byte relayPins[2] = {A0, A1};

// GLOBALS
// Declare the array of sensors
INA219 sensors[numSensors] = {
  INA219(0x40), // Default I2C address
  INA219(0x44) // I2C address when jumper A1 has been bridged to GND
};
// An array to record the starting reading of each sensor
float baseReading[numSensors];
// Array of running averages to smooth readings
RunningAverage averageReadings[numSensors] = {
  RunningAverage(5),
  RunningAverage(5)
};
// The amount by which power measured on each circuit needs to deviate 
// to be interpreted as a touch on the plasma ball
float tolerance = 0.05;

void setup(void)  {
  #ifdef DEBUG
    Serial.begin(115200);
    Serial.println(F("Starting setup..."));
  #endif

  // Setup the sensors
  for(int i=0;i<numSensors;i++){
    // Explicitly clear the running average value
    averageReadings[i].clear();
    // Start the sensor, with default configuration (range of <32V, <2A)
    // If you only need to monitor lower values, you can increase precision by reducing this range
    sensors[i].begin();
  }
  // Sample each sensor several times to get the average base reading
  for(int j=0; j<numSensors; j++){
    for(int k=0; k<5; k++){
      averageReadings[j].addValue(sensors[j].busPower());
      delay(50);
    }    
    // Assign the running average value to the array
    baseReading[j] = averageReadings[j].getAverage();
    #ifdef DEBUG
      Serial.print(F("Sensor "));
      Serial.print(j);
      Serial.print(F(" initialised with base reading "));
      Serial.println(baseReading[j]);
    #endif
  }

  // Initialise the relay pins 
  for(int i=0;i<2;i++){
    pinMode(relayPins[i], OUTPUT);
    digitalWrite(relayPins[i], LOW);
  }
  
  #ifdef DEBUG
    Serial.println(F("Setup complete."));
  #endif

  // Pause to let everything stabilise before running the main program loop
  delay(1000);
}

bool allBallsBeingTouched() {
  // If all the balls are being touched, then all sensor readings should be outside the
  // tolerance limit from their base (untouched) readings. Put another way, if any sensor
  // reading is *within* the tolerance, then all the balls can't be being touched:
  for(int i=0; i<numSensors; i++) {
    if((averageReadings[i].getAverage() - baseReading[i]) < tolerance) {
      return false;
    }
  }
  return true;
}

/* Make the linear actuator extend */
void extend() {
  digitalWrite(relayPins[0], LOW);
  digitalWrite(relayPins[1], HIGH);
}

/* Make the linear actuator contract */
void contract() {
  digitalWrite(relayPins[0], HIGH);
  digitalWrite(relayPins[1], LOW);
}

/* Main program loop */
void loop(void)  {
  // Loop over each sensor
  for(int i=0; i<numSensors; i++){
    
    // The bus power is the total power used by the circuit under test, as measured between GND and V- 
    float busPower = sensors[i].busPower();
    
    // Add the current reading to the running array
    averageReadings[i].addValue(busPower);

    #ifdef DEBUG
      Serial.print(averageReadings[i].getAverage());
      // Put comma delimiter between values
      if(i<numSensors-1) {Serial.print(",");}
    #endif
  }
  #ifdef DEBUG
    Serial.println("");
  #endif

  // Activate the actuator based on the inputs
  if(allBallsBeingTouched()) {
    extend();
  }
  else {
    contract();
  }

  // Introduce a slight delay before next polling the sensors
  delay(100);
}

This is the diagram

this is the erorr message that im getting

C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:29:14: error: invalid conversion from 'int' to 'INA219::t_i2caddr' [-fpermissive]
   INA219(0x40), // Default I2C address
              ^
In file included from C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:16:0:
C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\src\INA219\INA219.h:128:5: note:   initializing argument 1 of 'INA219::INA219(INA219::t_i2caddr)'
     INA219( t_i2caddr addr = I2C_ADDR_40 ///< Device address.
     ^~~~~~
C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:30:14: error: invalid conversion from 'int' to 'INA219::t_i2caddr' [-fpermissive]
   INA219(0x44) // I2C address when jumper A1 has been bridged to GND
              ^
In file included from C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:16:0:
C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\src\INA219\INA219.h:128:5: note:   initializing argument 1 of 'INA219::INA219(INA219::t_i2caddr)'
     INA219( t_i2caddr addr = I2C_ADDR_40 ///< Device address.
     ^~~~~~

exit status 1

Compilation error: invalid conversion from 'int' to 'INA219::t_i2caddr' [-fpermissive]

I expect the error messages you're getting, which you didn't see fit to include, might give us a ghost of a chance of telling you what's wrong.
Also, please edit your post to enclose your code listing as code, by placing it within code tags. At this point, just edit the post, select only the code, and press the little button at the top of the input box that is labelled...< code/ > In future, export your code from the IDE using shift-ctrl-C and just paste it into the message input box.

Hi @dannyben.

I'm going to ask you to provide the full output from an upload attempt.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Attempt an upload, just as you did before.
  2. Wait for the upload to fail.
  3. You will see an "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  6. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  7. Move the cursor outside of the code block markup before you add any additional text to your reply.
  8. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:
    Upload icon on toolbar
    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

Hi so this is the error that i keep getting

C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:29:14: error: invalid conversion from 'int' to 'INA219::t_i2caddr' [-fpermissive]
   INA219(0x40), // Default I2C address
              ^
In file included from C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:16:0:
C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\src\INA219\INA219.h:128:5: note:   initializing argument 1 of 'INA219::INA219(INA219::t_i2caddr)'
     INA219( t_i2caddr addr = I2C_ADDR_40 ///< Device address.
     ^~~~~~
C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:30:14: error: invalid conversion from 'int' to 'INA219::t_i2caddr' [-fpermissive]
   INA219(0x44) // I2C address when jumper A1 has been bridged to GND
              ^
In file included from C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\ARDUINO_CODE___PlasmaBall_copy_20240601141125.ino:16:0:
C:\Users\Global W design\OneDrive\Desktop\Arduino projects\PLASMA GAME\ARDUINO_CODE___PlasmaBall_copy_20240601141125\src\INA219\INA219.h:128:5: note:   initializing argument 1 of 'INA219::INA219(INA219::t_i2caddr)'
     INA219( t_i2caddr addr = I2C_ADDR_40 ///< Device address.
     ^~~~~~

exit status 1

Compilation error: invalid conversion from 'int' to 'INA219::t_i2caddr' [-fpermissive]

Ask someone to make it work or give your money back to you.

At this point ill pay somone that can fixe it and it make it work .... but i dont know anyone thats the problem like i said im brand new with this

What reasons made you pick this for your first project?

It's a project that im.working on for my job

You missed the "object" in declaring an object.... so this...

Should look like this...

INA219 INA(0x40),
INA219 INB(0x44) // I think you want two object with different names

From where did you copy the program?

If you have copied working code, you might try to silence all warnings from the compiler. It might work, since at least some of the errors are fpermissive....
This indicates that the code that came with the game is sloppy written....
As an example a variable of i2caddress type is expected. You give an integer...
Most probably the i2caddress represents a pin number. Therefore an int will probably interpreted as a pin number. Which often is equal to the pin number printed on the board...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.