1602

ksilius
Offline
Зарегистрирован: 12.04.2022

Здравствуйте, хочу повторить схему металлоискателя на ардуино, есть такой код, в коде есть дисплей 1602 без адаптера I2C у меня адаптер запаян и не хочется отпаивать. Прошу помощи в прописке данного адаптера в этот код. Сам пробовал вставлять адаптер с адресом закоментировав при этом выводы на дисплей но вылазит ошибка.

// Induction balance metal detector

// We run the CPU at 16MHz and the ADC clock at 1MHz. ADC resolution is reduced to 8 bits at this speed.

// Timer 1 is used to divide the system clock by about 256 to produce a 62.5kHz square wave. 
// This is used to drive timer 0 and also to trigger ADC conversions.
// Timer 0 is used to divide the output of timer 1 by 8, giving a 7.8125kHz signal for driving the transmit coil.
// This gives us 16 ADC clock cycles for each ADC conversion (it actually takes 13.5 cycles), and we take 8 samples per cycle of the coil drive voltage.
// The ADC implements four phase-sensitive detectors at 45 degree intervals. Using 4 instead of just 2 allows us to cancel the third harmonic of the
// coil frequency.

// Timer 2 will be used to generate a tone for the earpiece or headset.

// Other division ratios for timer 1 are possible, from about 235 upwards.

// Wiring:
// Connect digital pin 4 (alias T0) to digital pin 9
// Connect digital pin 5 through resistor to primary coil and tuning capacitor
// Connect output from receive amplifier to analog pin 0. Output of receive amplifier should be biased to about half of the analog reference.
// When using USB power, change analog reference to the 3.3V pin, because there is too much noise on the +5V rail to get good sensitivity.
#include <LiquidCrystal.h> 
#include <LcdBarGraph.h>
#define max_ampAverage 200
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
LcdBarGraph lbg(&lcd, 16, 0, 1); 

#define TIMER1_TOP  (259)        // can adjust this to fine-tune the frequency to get the coil tuned (see above)

#define USE_3V3_AREF  (1)        // set to 1 of running on an Arduino with USB power, 0 for an embedded atmega28p with no 3.3V supply available

// Digital pin definitions
// Digital pin 0 not used, however if we are using the serial port for debugging then it's serial input
const int debugTxPin = 1;        // transmit pin reserved for debugging
const int encoderButtonPin = 2;  // encoder button, also IN0 for waking up from sleep mode
const int earpiecePin = 3;       // earpiece, aka OCR2B for tone generation
const int T0InputPin = 4;
const int coilDrivePin = 5;
const int LcdRsPin = 6;
const int LcdEnPin = 7;
const int LcdPowerPin = 8;       // LCD power and backlight enable
const int T0OutputPin = 9;
const int lcdD4Pin = 10;
const int lcdD5Pin = 11;         // pins 11-13 also used for ICSP
const int LcdD6Pin = 12;
const int LcdD7Pin = 13;

// Analog pin definitions
const int receiverInputPin = 0;
const int encoderAPin = A1;
const int encoderBpin = A2;
// Analog pins 3-5 not used

// Variables used only by the ISR
int16_t bins[4];                 // bins used to accumulate ADC readings, one for each of the 4 phases
uint16_t numSamples = 0;
const uint16_t numSamplesToAverage = 1024;

// Variables used by the ISR and outside it
volatile int16_t averages[4];    // when we've accumulated enough readings in the bins, the ISR copies them to here and starts again
volatile uint32_t ticks = 0;     // system tick counter for timekeeping
volatile bool sampleReady = false;  // indicates that the averages array has been updated

// Variables used only outside the ISR
int16_t calib[4];                // values (set during calibration) that we subtract from the averages

volatile uint8_t lastctr;
volatile uint16_t misses = 0;    // this counts how many times the ISR has been executed too late. Should remain at zero if everything is working properly.

const double halfRoot2 = sqrt(0.5);
const double quarterPi = 3.1415927/4.0;
const double radiansToDegrees = 180.0/3.1415927;

// The ADC sample and hold occurs 2 ADC clocks (= 32 system clocks) after the timer 1 overflow flag is set.
// This introduces a slight phase error, which we adjust for in the calculations.
const float phaseAdjust = (45.0 * 32.0)/(float)(TIMER1_TOP + 1);

float threshold = 5.0;          // lower = greater sensitivity. 10 is just about usable with a well-balanced coil.
                                 // The user will be able to adjust this via a pot or rotary encoder.

void setup()
{
  lcd.begin(16, 2);// LCD 16X2
  pinMode(encoderButtonPin, INPUT_PULLUP);  
  digitalWrite(T0OutputPin, LOW);
  pinMode(T0OutputPin, OUTPUT);       // pulse pin from timer 1 used to feed timer 0
  digitalWrite(coilDrivePin, LOW);
  pinMode(coilDrivePin, OUTPUT);      // timer 0 output, square wave to drive transmit coil
  
  cli();
  // Stop timer 0 which was set up by the Arduino core
  TCCR0B = 0;        // stop the timer
  TIMSK0 = 0;        // disable interrupt
  TIFR0 = 0x07;      // clear any pending interrupt
  
  // Set up ADC to trigger and read channel 0 on timer 1 overflow
#if USE_3V3_AREF
  ADMUX = (1 << ADLAR);                   // use AREF pin (connected to 3.3V) as voltage reference, read pin A0, left-adjust result
#else
  ADMUX = (1 << REFS0) | (1 << ADLAR);    // use Avcc as voltage reference, read pin A0, left-adjust result
#endif  
  ADCSRB = (1 << ADTS2) | (1 << ADTS1);   // auto-trigger ADC on timer/counter 1 overflow
  ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | (1 << ADPS2);  // enable adc, enable auto-trigger, prescaler = 16 (1MHz ADC clock)
  DIDR0 = 1;

  // Set up timer 1.
  // Prescaler = 1, phase correct PWM mode, TOP = ICR1A
  TCCR1A = (1 << COM1A1) | (1 << WGM11);
  TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10);    // CTC mode, prescaler = 1
  TCCR1C = 0;
  OCR1AH = (TIMER1_TOP/2 >> 8);
  OCR1AL = (TIMER1_TOP/2 & 0xFF);
  ICR1H = (TIMER1_TOP >> 8);
  ICR1L = (TIMER1_TOP & 0xFF);
  TCNT1H = 0;
  TCNT1L = 0;
  TIFR1 = 0x07;      // clear any pending interrupt
  TIMSK1 = (1 << TOIE1);

  // Set up timer 0
  // Clock source = T0, fast PWM mode, TOP (OCR0A) = 7, PWM output on OC0B
  TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);
  TCCR0B = (1 << CS00) | (1 << CS01) | (1 << CS02) | (1 << WGM02);
  OCR0A = 7;
  OCR0B = 3;
  TCNT0 = 0;
  sei();
  
  while (!sampleReady) {}    // discard the first sample
  misses = 0;
  sampleReady = false;
  
  Serial.begin(19200); 
}

// Timer 0 overflow interrupt. This serves 2 purposes:
// 1. It clears the timer 0 overflow flag. If we don't do this, the ADC will not see any more Timer 0 overflows and we will not get any more conversions.
// 2. It increments the tick counter, allowing is to do timekeeping. We get 62500 ticks/second.
// We now read the ADC in the timer interrupt routine instead of having a separate comversion complete interrupt.
ISR(TIMER1_OVF_vect)
{
  ++ticks;
  uint8_t ctr = TCNT0;
  int16_t val = (int16_t)(uint16_t)ADCH;    // only need to read most significant 8 bits
  if (ctr != ((lastctr + 1) & 7))
  {
    ++misses;
  }
  lastctr = ctr;
  int16_t *p = &bins[ctr & 3];
  if (ctr < 4)
  {
    *p += (val);
    if (*p > 15000) *p = 15000;
  }
  else
  {
    *p -= val;
    if (*p < -15000) *p = -15000;
  } 
  if (ctr == 7)
  {
    ++numSamples;
    if (numSamples == numSamplesToAverage)
    {
      numSamples = 0;
      if (!sampleReady)      // if previous sample has been consumed
      {
        memcpy((void*)averages, bins, sizeof(averages));
        sampleReady = true;
      }
      memset(bins, 0, sizeof(bins));
    }
  }
}

void loop()
{
  while (!sampleReady) {}
  uint32_t oldTicks = ticks;
  
  if (digitalRead(encoderButtonPin) == LOW)
  {
    // Calibrate button pressed. We save the current phase detector outputs and subtract them from future results.
    // This lets us use the detector if the coil is slightly off-balance.
    // It would be better to everage several samples instead of taking just one.
    for (int i = 0; i < 4; ++i)
    {
      calib[i] = averages[i];
    }
    sampleReady = false;
    Serial.print("Calibrated: ");
    
    lcd.setCursor(0,0);
    lcd.print("Calibrating...  ");    
    for (int i = 0; i < 4; ++i)
    {
      Serial.write(' ');
      
      Serial.print(calib[i]);
    
    lcd.setCursor(0,1);    
    lcd.print(' ');    
    lcd.print(calib[4]); 
    lcd.print("        ");     
    }
    Serial.println();
  }
  else
  {  
    for (int i = 0; i < 4; ++i)
    {
      averages[i] -= calib[i];
    }
    const double f = 200.0;
    
    // Massage the results to eliminate sensitivity to the 3rd harmonic, and divide by 200
    double bin0 = (averages[0] + halfRoot2 * (averages[1] - averages[3]))/f;
    double bin1 = (averages[1] + halfRoot2 * (averages[0] + averages[2]))/f;
    double bin2 = (averages[2] + halfRoot2 * (averages[1] + averages[3]))/f;
    double bin3 = (averages[3] + halfRoot2 * (averages[2] - averages[0]))/f;
    sampleReady = false;          // we've finished reading the averages, so the ISR is free to overwrite them again

    double amp1 = sqrt((bin0 * bin0) + (bin2 * bin2));
    double amp2 = sqrt((bin1 * bin1) + (bin3 * bin3));
    double ampAverage = (amp1 + amp2)/2.0;
    
    // The ADC sample/hold takes place 2 clocks after the timer overflow
    double phase1 = atan2(bin0, bin2) * radiansToDegrees + 45.0;
    double phase2 = atan2(bin1, bin3) * radiansToDegrees;
  
    if (phase1 > phase2)
    {
      double temp = phase1;
      phase1 = phase2;
      phase2 = temp;
    }
    
    double phaseAverage = ((phase1 + phase2)/2.0) - phaseAdjust;
    if (phase2 - phase1 > 180.0)
    { 
      if (phaseAverage < 0.0)
      {
        phaseAverage += 180.0;
      }
      else
      {
        phaseAverage -= 180.0;
      }
    }
        
    // For diagnostic purposes, print the individual bin counts and the 2 indepedently-calculated gains and phases                                                        
    Serial.print(misses);
    Serial.write(' ');
    
    if (bin0 >= 0.0) Serial.write(' ');
    Serial.print(bin0, 2);
    Serial.write(' ');
    if (bin1 >= 0.0) Serial.write(' ');
    Serial.print(bin1, 2);
    Serial.write(' ');
    if (bin2 >= 0.0) Serial.write(' ');
    Serial.print(bin2, 2);
    Serial.write(' ');
    if (bin3 >= 0.0) Serial.write(' ');
    Serial.print(bin3, 2);
    Serial.print("    ");
    Serial.print(amp1, 2);
    Serial.write(' ');
    Serial.print(amp2, 2);
    Serial.write(' ');
    if (phase1 >= 0.0) Serial.write(' ');
    Serial.print(phase1, 2);
    Serial.write(' ');
    if (phase2 >= 0.0) Serial.write(' ');
    Serial.print(phase2, 2);
    Serial.print("    ");
    
    // Print the final amplitude and phase, which we use to decide what (if anything) we have found)
    if (ampAverage >= 0.0) Serial.write(' ');
    Serial.print(ampAverage, 1);
    Serial.write(' ');
        
        lcd.setCursor(0,0);
        lcd.print("          ");
        lcd.print(ampAverage);        
        lcd.setCursor(0,1);
        lbg.drawValue(ampAverage, max_ampAverage);

    if (phaseAverage >= 0.0) Serial.write(' ');
    Serial.print((int)phaseAverage);
    
    // Decide what we have found and tell the user
    if (ampAverage >= threshold)
    {
      // When held in line with the centre of the coil:
      // - non-ferrous metals give a negative phase shift, e.g. -90deg for thick copper or aluminium, a copper olive, -30deg for thin alumimium.
      // Ferrous metals give zero phase shift or a small positive phase shift.
      // So we'll say that anything with a phase shift below -20deg is non-ferrous.
      if (phaseAverage < -20.0)
      {
        Serial.print(" Non-ferrous");
        lcd.setCursor(0,0);        
        lcd.print("NonFerous ");      
     
      }
      else
      {
        Serial.print(" Ferrous");        
        lcd.setCursor(0,0);       
        lcd.print("Ferrous    ");                 
      }
      float temp = ampAverage;
              
       int thisPitch = map (temp, 10, 200, 100, 1500);
       tone(3, thisPitch,120);
       
      while (temp > threshold)
      {
        Serial.write('!');      
        temp -= (threshold/2);
      }
    }   
    Serial.println();
   
   }
  while (ticks - oldTicks < 8000)
  {
  }      
}

 

v258
v258 аватар
Offline
Зарегистрирован: 25.05.2020

Вместо библиотеки LiquidCrystal используйте библиотеку LiquidCrystal_I2C

ksilius
Offline
Зарегистрирован: 12.04.2022

Все библиотеки на месте и работаю проверено на хало ворлд. Я может чуть знаю что такое ардуино верхушек нахватался но осоцилограф на ардуино спаял.

 

b707
Offline
Зарегистрирован: 26.05.2017

ksilius пишет:

Все библиотеки на месте и работаю проверено на хало ворлд.

если "все библиотеки на месте и работают" - в чем тогда вопрос?

v258
v258 аватар
Offline
Зарегистрирован: 25.05.2020

Еще раз - Вместо библиотеки LiquidCrystal используйте библиотеку LiquidCrystal_I2C

Или буковки I2C в конце названия ни о чем не говорят?

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

v258 пишет:

Еще раз - Вместо библиотеки LiquidCrystal используйте библиотеку LiquidCrystal_I2C

Или буковки I2C в конце названия ни о чем не говорят?

Этого мало, библиотеку LcdBarGraph.h тоже надо под I2C переписать, это не сложно, но ведь надо )))

как-то так:
 

// Induction balance metal detector

// We run the CPU at 16MHz and the ADC clock at 1MHz. ADC resolution is reduced to 8 bits at this speed.

// Timer 1 is used to divide the system clock by about 256 to produce a 62.5kHz square wave. 
// This is used to drive timer 0 and also to trigger ADC conversions.
// Timer 0 is used to divide the output of timer 1 by 8, giving a 7.8125kHz signal for driving the transmit coil.
// This gives us 16 ADC clock cycles for each ADC conversion (it actually takes 13.5 cycles), and we take 8 samples per cycle of the coil drive voltage.
// The ADC implements four phase-sensitive detectors at 45 degree intervals. Using 4 instead of just 2 allows us to cancel the third harmonic of the
// coil frequency.

// Timer 2 will be used to generate a tone for the earpiece or headset.

// Other division ratios for timer 1 are possible, from about 235 upwards.

// Wiring:
// Connect digital pin 4 (alias T0) to digital pin 9
// Connect digital pin 5 through resistor to primary coil and tuning capacitor
// Connect output from receive amplifier to analog pin 0. Output of receive amplifier should be biased to about half of the analog reference.
// When using USB power, change analog reference to the 3.3V pin, because there is too much noise on the +5V rail to get good sensitivity.

#define LCDI2C

#ifndef LCDI2C
#include <LiquidCrystal.h> 
#include <LcdBarGraph.h> 
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
LcdBarGraph lbg(&lcd, 16, 0, 1);        // https://github.com/prampec/LcdBarGraph
#else
#include <LiquidCrystal_I2C.h>          // https://github.com/troublegum/liquidcrystal_i2c
#include <LcdBarGraph_I2C.h>  
LiquidCrystal_I2C lcd(0x27,16,2);
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1); 
#endif


#define max_ampAverage 200

#define TIMER1_TOP  (259)        // can adjust this to fine-tune the frequency to get the coil tuned (see above)

#define USE_3V3_AREF  (1)        // set to 1 of running on an Arduino with USB power, 0 for an embedded atmega28p with no 3.3V supply available

// Digital pin definitions
// Digital pin 0 not used, however if we are using the serial port for debugging then it's serial input
const int debugTxPin = 1;        // transmit pin reserved for debugging
const int encoderButtonPin = 2;  // encoder button, also IN0 for waking up from sleep mode
const int earpiecePin = 3;       // earpiece, aka OCR2B for tone generation
const int T0InputPin = 4;
const int coilDrivePin = 5;
const int LcdRsPin = 6;
const int LcdEnPin = 7;
const int LcdPowerPin = 8;       // LCD power and backlight enable
const int T0OutputPin = 9;
const int lcdD4Pin = 10;
const int lcdD5Pin = 11;         // pins 11-13 also used for ICSP
const int LcdD6Pin = 12;
const int LcdD7Pin = 13;

// Analog pin definitions
const int receiverInputPin = 0;
const int encoderAPin = A1;
const int encoderBpin = A2;
// Analog pins 3-5 not used

// Variables used only by the ISR
int16_t bins[4];                 // bins used to accumulate ADC readings, one for each of the 4 phases
uint16_t numSamples = 0;
const uint16_t numSamplesToAverage = 1024;

// Variables used by the ISR and outside it
volatile int16_t averages[4];    // when we've accumulated enough readings in the bins, the ISR copies them to here and starts again
volatile uint32_t ticks = 0;     // system tick counter for timekeeping
volatile bool sampleReady = false;  // indicates that the averages array has been updated

// Variables used only outside the ISR
int16_t calib[4];                // values (set during calibration) that we subtract from the averages

volatile uint8_t lastctr;
volatile uint16_t misses = 0;    // this counts how many times the ISR has been executed too late. Should remain at zero if everything is working properly.

const double halfRoot2 = sqrt(0.5);
const double quarterPi = 3.1415927/4.0;
const double radiansToDegrees = 180.0/3.1415927;

// The ADC sample and hold occurs 2 ADC clocks (= 32 system clocks) after the timer 1 overflow flag is set.
// This introduces a slight phase error, which we adjust for in the calculations.
const float phaseAdjust = (45.0 * 32.0)/(float)(TIMER1_TOP + 1);

float threshold = 5.0;          // lower = greater sensitivity. 10 is just about usable with a well-balanced coil.
                                 // The user will be able to adjust this via a pot or rotary encoder.

void setup()
{
  lcd.begin(16, 2);// LCD 16X2
  pinMode(encoderButtonPin, INPUT_PULLUP);  
  digitalWrite(T0OutputPin, LOW);
  pinMode(T0OutputPin, OUTPUT);       // pulse pin from timer 1 used to feed timer 0
  digitalWrite(coilDrivePin, LOW);
  pinMode(coilDrivePin, OUTPUT);      // timer 0 output, square wave to drive transmit coil
  
  cli();
  // Stop timer 0 which was set up by the Arduino core
  TCCR0B = 0;        // stop the timer
  TIMSK0 = 0;        // disable interrupt
  TIFR0 = 0x07;      // clear any pending interrupt
  
  // Set up ADC to trigger and read channel 0 on timer 1 overflow
#if USE_3V3_AREF
  ADMUX = (1 << ADLAR);                   // use AREF pin (connected to 3.3V) as voltage reference, read pin A0, left-adjust result
#else
  ADMUX = (1 << REFS0) | (1 << ADLAR);    // use Avcc as voltage reference, read pin A0, left-adjust result
#endif  
  ADCSRB = (1 << ADTS2) | (1 << ADTS1);   // auto-trigger ADC on timer/counter 1 overflow
  ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | (1 << ADPS2);  // enable adc, enable auto-trigger, prescaler = 16 (1MHz ADC clock)
  DIDR0 = 1;

  // Set up timer 1.
  // Prescaler = 1, phase correct PWM mode, TOP = ICR1A
  TCCR1A = (1 << COM1A1) | (1 << WGM11);
  TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10);    // CTC mode, prescaler = 1
  TCCR1C = 0;
  OCR1AH = (TIMER1_TOP/2 >> 8);
  OCR1AL = (TIMER1_TOP/2 & 0xFF);
  ICR1H = (TIMER1_TOP >> 8);
  ICR1L = (TIMER1_TOP & 0xFF);
  TCNT1H = 0;
  TCNT1L = 0;
  TIFR1 = 0x07;      // clear any pending interrupt
  TIMSK1 = (1 << TOIE1);

  // Set up timer 0
  // Clock source = T0, fast PWM mode, TOP (OCR0A) = 7, PWM output on OC0B
  TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);
  TCCR0B = (1 << CS00) | (1 << CS01) | (1 << CS02) | (1 << WGM02);
  OCR0A = 7;
  OCR0B = 3;
  TCNT0 = 0;
  sei();
  
  while (!sampleReady) {}    // discard the first sample
  misses = 0;
  sampleReady = false;
  
  Serial.begin(19200); 
}

// Timer 0 overflow interrupt. This serves 2 purposes:
// 1. It clears the timer 0 overflow flag. If we don't do this, the ADC will not see any more Timer 0 overflows and we will not get any more conversions.
// 2. It increments the tick counter, allowing is to do timekeeping. We get 62500 ticks/second.
// We now read the ADC in the timer interrupt routine instead of having a separate comversion complete interrupt.
ISR(TIMER1_OVF_vect)
{
  ++ticks;
  uint8_t ctr = TCNT0;
  int16_t val = (int16_t)(uint16_t)ADCH;    // only need to read most significant 8 bits
  if (ctr != ((lastctr + 1) & 7))
  {
    ++misses;
  }
  lastctr = ctr;
  int16_t *p = &bins[ctr & 3];
  if (ctr < 4)
  {
    *p += (val);
    if (*p > 15000) *p = 15000;
  }
  else
  {
    *p -= val;
    if (*p < -15000) *p = -15000;
  } 
  if (ctr == 7)
  {
    ++numSamples;
    if (numSamples == numSamplesToAverage)
    {
      numSamples = 0;
      if (!sampleReady)      // if previous sample has been consumed
      {
        memcpy((void*)averages, bins, sizeof(averages));
        sampleReady = true;
      }
      memset(bins, 0, sizeof(bins));
    }
  }
}

void loop()
{
  while (!sampleReady) {}
  uint32_t oldTicks = ticks;
  
  if (digitalRead(encoderButtonPin) == LOW)
  {
    // Calibrate button pressed. We save the current phase detector outputs and subtract them from future results.
    // This lets us use the detector if the coil is slightly off-balance.
    // It would be better to everage several samples instead of taking just one.
    for (int i = 0; i < 4; ++i)
    {
      calib[i] = averages[i];
    }
    sampleReady = false;
    Serial.print("Calibrated: ");
    
    lcd.setCursor(0,0);
    lcd.print("Calibrating...  ");    
    for (int i = 0; i < 4; ++i)
    {
      Serial.write(' ');
      
      Serial.print(calib[i]);
    
    lcd.setCursor(0,1);    
    lcd.print(' ');    
    lcd.print(calib[4]); 
    lcd.print("        ");     
    }
    Serial.println();
  }
  else
  {  
    for (int i = 0; i < 4; ++i)
    {
      averages[i] -= calib[i];
    }
    const double f = 200.0;
    
    // Massage the results to eliminate sensitivity to the 3rd harmonic, and divide by 200
    double bin0 = (averages[0] + halfRoot2 * (averages[1] - averages[3]))/f;
    double bin1 = (averages[1] + halfRoot2 * (averages[0] + averages[2]))/f;
    double bin2 = (averages[2] + halfRoot2 * (averages[1] + averages[3]))/f;
    double bin3 = (averages[3] + halfRoot2 * (averages[2] - averages[0]))/f;
    sampleReady = false;          // we've finished reading the averages, so the ISR is free to overwrite them again

    double amp1 = sqrt((bin0 * bin0) + (bin2 * bin2));
    double amp2 = sqrt((bin1 * bin1) + (bin3 * bin3));
    double ampAverage = (amp1 + amp2)/2.0;
    
    // The ADC sample/hold takes place 2 clocks after the timer overflow
    double phase1 = atan2(bin0, bin2) * radiansToDegrees + 45.0;
    double phase2 = atan2(bin1, bin3) * radiansToDegrees;
  
    if (phase1 > phase2)
    {
      double temp = phase1;
      phase1 = phase2;
      phase2 = temp;
    }
    
    double phaseAverage = ((phase1 + phase2)/2.0) - phaseAdjust;
    if (phase2 - phase1 > 180.0)
    { 
      if (phaseAverage < 0.0)
      {
        phaseAverage += 180.0;
      }
      else
      {
        phaseAverage -= 180.0;
      }
    }
        
    // For diagnostic purposes, print the individual bin counts and the 2 indepedently-calculated gains and phases                                                        
    Serial.print(misses);
    Serial.write(' ');
    
    if (bin0 >= 0.0) Serial.write(' ');
    Serial.print(bin0, 2);
    Serial.write(' ');
    if (bin1 >= 0.0) Serial.write(' ');
    Serial.print(bin1, 2);
    Serial.write(' ');
    if (bin2 >= 0.0) Serial.write(' ');
    Serial.print(bin2, 2);
    Serial.write(' ');
    if (bin3 >= 0.0) Serial.write(' ');
    Serial.print(bin3, 2);
    Serial.print("    ");
    Serial.print(amp1, 2);
    Serial.write(' ');
    Serial.print(amp2, 2);
    Serial.write(' ');
    if (phase1 >= 0.0) Serial.write(' ');
    Serial.print(phase1, 2);
    Serial.write(' ');
    if (phase2 >= 0.0) Serial.write(' ');
    Serial.print(phase2, 2);
    Serial.print("    ");
    
    // Print the final amplitude and phase, which we use to decide what (if anything) we have found)
    if (ampAverage >= 0.0) Serial.write(' ');
    Serial.print(ampAverage, 1);
    Serial.write(' ');
        
        lcd.setCursor(0,0);
        lcd.print("          ");
        lcd.print(ampAverage);        
        lcd.setCursor(0,1);
        lbg.drawValue(ampAverage, max_ampAverage);

    if (phaseAverage >= 0.0) Serial.write(' ');
    Serial.print((int)phaseAverage);
    
    // Decide what we have found and tell the user
    if (ampAverage >= threshold)
    {
      // When held in line with the centre of the coil:
      // - non-ferrous metals give a negative phase shift, e.g. -90deg for thick copper or aluminium, a copper olive, -30deg for thin alumimium.
      // Ferrous metals give zero phase shift or a small positive phase shift.
      // So we'll say that anything with a phase shift below -20deg is non-ferrous.
      if (phaseAverage < -20.0)
      {
        Serial.print(" Non-ferrous");
        lcd.setCursor(0,0);        
        lcd.print("NonFerous ");      
     
      }
      else
      {
        Serial.print(" Ferrous");        
        lcd.setCursor(0,0);       
        lcd.print("Ferrous    ");                 
      }
      float temp = ampAverage;
              
       int thisPitch = map (temp, 10, 200, 100, 1500);
       tone(3, thisPitch,120);
       
      while (temp > threshold)
      {
        Serial.write('!');      
        temp -= (threshold/2);
      }
    }   
    Serial.println();
   
   }
  while (ticks - oldTicks < 8000)
  {
  }      
}
Скетч использует 11164 байт (34%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 588 байт (28%) динамической памяти, оставляя 1460 байт для локальных переменных. Максимум: 2048 байт.

 

BOOM
BOOM аватар
Offline
Зарегистрирован: 14.11.2018

Мошт #ifndef  твой "наоборот" ? ))

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

BOOM пишет:

Мошт #ifndef  твой "наоборот" ? ))

НЕА, так задумано, если библиотекаф  i2c НЕТУ КОМПИЛИРОВАТЬСЯ ПОД ОБЫЧНЫЕ

//#define LCDI2C

#ifndef LCDI2C
#include <LiquidCrystal.h> 
#include <LcdBarGraph.h> 
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
LcdBarGraph lbg(&lcd, 16, 0, 1);        // https://github.com/prampec/LcdBarGraph
#else
#include <LiquidCrystal_I2C.h>          // https://github.com/troublegum/liquidcrystal_i2c
#include <LcdBarGraph_I2C.h>  
LiquidCrystal_I2C lcd(0x27,16,2);
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1); 
#endif

 

Скетч использует 10702 байт (33%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 526 байт (25%) динамической памяти, оставляя 1522 байт для локальных переменных. Максимум: 2048 байт.

 

ksilius
Offline
Зарегистрирован: 12.04.2022

В холоу ворде работают в этом коде видимо нет.

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

ksilius пишет:

В холоу ворде работают в этом коде видимо нет.

блюда надо уметь готовить )))

BOOM
BOOM аватар
Offline
Зарегистрирован: 14.11.2018

ua6em пишет:

BOOM пишет:

Мошт #ifndef  твой "наоборот" ? ))

НЕА, так задумано, если библиотекаф  i2c НЕТУ КОМПИЛИРОВАТЬСЯ ПОД ОБЫЧНЫЕ

//#define LCDI2C

#ifndef LCDI2C
#include <LiquidCrystal.h> 
#include <LcdBarGraph.h> 
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
LcdBarGraph lbg(&lcd, 16, 0, 1);        // https://github.com/prampec/LcdBarGraph
#else
#include <LiquidCrystal_I2C.h>          // https://github.com/troublegum/liquidcrystal_i2c
#include <LcdBarGraph_I2C.h>  
LiquidCrystal_I2C lcd(0x27,16,2);
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1); 
#endif

 

Скетч использует 10702 байт (33%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 526 байт (25%) динамической памяти, оставляя 1522 байт для локальных переменных. Максимум: 2048 байт.

Не логично. Если ты объявляешь LCDI2C, то и подключай I2C-бибилиотеки. Так же по логике должно быть?...

ksilius
Offline
Зарегистрирован: 12.04.2022

Я правил так но у меня вылетает ошибка при компеляции.

// Induction balance metal detector

// We run the CPU at 16MHz and the ADC clock at 1MHz. ADC resolution is reduced to 8 bits at this speed.

// Timer 1 is used to divide the system clock by about 256 to produce a 62.5kHz square wave. 
// This is used to drive timer 0 and also to trigger ADC conversions.
// Timer 0 is used to divide the output of timer 1 by 8, giving a 7.8125kHz signal for driving the transmit coil.
// This gives us 16 ADC clock cycles for each ADC conversion (it actually takes 13.5 cycles), and we take 8 samples per cycle of the coil drive voltage.
// The ADC implements four phase-sensitive detectors at 45 degree intervals. Using 4 instead of just 2 allows us to cancel the third harmonic of the
// coil frequency.

// Timer 2 will be used to generate a tone for the earpiece or headset.

// Other division ratios for timer 1 are possible, from about 235 upwards.

// Wiring:
// Connect digital pin 4 (alias T0) to digital pin 9
// Connect digital pin 5 through resistor to primary coil and tuning capacitor
// Connect output from receive amplifier to analog pin 0. Output of receive amplifier should be biased to about half of the analog reference.
// When using USB power, change analog reference to the 3.3V pin, because there is too much noise on the +5V rail to get good sensitivity.
//#include <LiquidCrystal.h> 
//#include <LcdBarGraph.h>
//#define max_ampAverage 200
//LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
//LcdBarGraph lbg(&lcd, 16, 0, 1); 
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27,16,2); //0x20 ; ox27 ; 0x3F
#define TIMER1_TOP  (259)        // can adjust this to fine-tune the frequency to get the coil tuned (see above)

#define USE_3V3_AREF  (1)        // set to 1 of running on an Arduino with USB power, 0 for an embedded atmega28p with no 3.3V supply available

// Digital pin definitions
// Digital pin 0 not used, however if we are using the serial port for debugging then it's serial input
const int debugTxPin = 1;        // transmit pin reserved for debugging
const int encoderButtonPin = 2;  // encoder button, also IN0 for waking up from sleep mode
const int earpiecePin = 3;       // earpiece, aka OCR2B for tone generation
const int T0InputPin = 4;
const int coilDrivePin = 5;
const int LcdRsPin = 6;
const int LcdEnPin = 7;
const int LcdPowerPin = 8;       // LCD power and backlight enable
const int T0OutputPin = 9;
const int lcdD4Pin = 10;
const int lcdD5Pin = 11;         // pins 11-13 also used for ICSP
const int LcdD6Pin = 12;
const int LcdD7Pin = 13;

// Analog pin definitions
const int receiverInputPin = 0;
const int encoderAPin = A1;
const int encoderBpin = A2;
// Analog pins 3-5 not used

// Variables used only by the ISR
int16_t bins[4];                 // bins used to accumulate ADC readings, one for each of the 4 phases
uint16_t numSamples = 0;
const uint16_t numSamplesToAverage = 1024;

// Variables used by the ISR and outside it
volatile int16_t averages[4];    // when we've accumulated enough readings in the bins, the ISR copies them to here and starts again
volatile uint32_t ticks = 0;     // system tick counter for timekeeping
volatile bool sampleReady = false;  // indicates that the averages array has been updated

// Variables used only outside the ISR
int16_t calib[4];                // values (set during calibration) that we subtract from the averages

volatile uint8_t lastctr;
volatile uint16_t misses = 0;    // this counts how many times the ISR has been executed too late. Should remain at zero if everything is working properly.

const double halfRoot2 = sqrt(0.5);
const double quarterPi = 3.1415927/4.0;
const double radiansToDegrees = 180.0/3.1415927;

// The ADC sample and hold occurs 2 ADC clocks (= 32 system clocks) after the timer 1 overflow flag is set.
// This introduces a slight phase error, which we adjust for in the calculations.
const float phaseAdjust = (45.0 * 32.0)/(float)(TIMER1_TOP + 1);

float threshold = 5.0;          // lower = greater sensitivity. 10 is just about usable with a well-balanced coil.
                                 // The user will be able to adjust this via a pot or rotary encoder.

void setup()
{
  lcd.begin(16, 2);// LCD 16X2
  pinMode(encoderButtonPin, INPUT_PULLUP);  
  digitalWrite(T0OutputPin, LOW);
  pinMode(T0OutputPin, OUTPUT);       // pulse pin from timer 1 used to feed timer 0
  digitalWrite(coilDrivePin, LOW);
  pinMode(coilDrivePin, OUTPUT);      // timer 0 output, square wave to drive transmit coil
  
  cli();
  // Stop timer 0 which was set up by the Arduino core
  TCCR0B = 0;        // stop the timer
  TIMSK0 = 0;        // disable interrupt
  TIFR0 = 0x07;      // clear any pending interrupt
  
  // Set up ADC to trigger and read channel 0 on timer 1 overflow
#if USE_3V3_AREF
  ADMUX = (1 << ADLAR);                   // use AREF pin (connected to 3.3V) as voltage reference, read pin A0, left-adjust result
#else
  ADMUX = (1 << REFS0) | (1 << ADLAR);    // use Avcc as voltage reference, read pin A0, left-adjust result
#endif  
  ADCSRB = (1 << ADTS2) | (1 << ADTS1);   // auto-trigger ADC on timer/counter 1 overflow
  ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | (1 << ADPS2);  // enable adc, enable auto-trigger, prescaler = 16 (1MHz ADC clock)
  DIDR0 = 1;

  // Set up timer 1.
  // Prescaler = 1, phase correct PWM mode, TOP = ICR1A
  TCCR1A = (1 << COM1A1) | (1 << WGM11);
  TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10);    // CTC mode, prescaler = 1
  TCCR1C = 0;
  OCR1AH = (TIMER1_TOP/2 >> 8);
  OCR1AL = (TIMER1_TOP/2 & 0xFF);
  ICR1H = (TIMER1_TOP >> 8);
  ICR1L = (TIMER1_TOP & 0xFF);
  TCNT1H = 0;
  TCNT1L = 0;
  TIFR1 = 0x07;      // clear any pending interrupt
  TIMSK1 = (1 << TOIE1);

  // Set up timer 0
  // Clock source = T0, fast PWM mode, TOP (OCR0A) = 7, PWM output on OC0B
  TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);
  TCCR0B = (1 << CS00) | (1 << CS01) | (1 << CS02) | (1 << WGM02);
  OCR0A = 7;
  OCR0B = 3;
  TCNT0 = 0;
  sei();
  
  while (!sampleReady) {}    // discard the first sample
  misses = 0;
  sampleReady = false;
  
  Serial.begin(19200); 
}

// Timer 0 overflow interrupt. This serves 2 purposes:
// 1. It clears the timer 0 overflow flag. If we don't do this, the ADC will not see any more Timer 0 overflows and we will not get any more conversions.
// 2. It increments the tick counter, allowing is to do timekeeping. We get 62500 ticks/second.
// We now read the ADC in the timer interrupt routine instead of having a separate comversion complete interrupt.
ISR(TIMER1_OVF_vect)
{
  ++ticks;
  uint8_t ctr = TCNT0;
  int16_t val = (int16_t)(uint16_t)ADCH;    // only need to read most significant 8 bits
  if (ctr != ((lastctr + 1) & 7))
  {
    ++misses;
  }
  lastctr = ctr;
  int16_t *p = &bins[ctr & 3];
  if (ctr < 4)
  {
    *p += (val);
    if (*p > 15000) *p = 15000;
  }
  else
  {
    *p -= val;
    if (*p < -15000) *p = -15000;
  } 
  if (ctr == 7)
  {
    ++numSamples;
    if (numSamples == numSamplesToAverage)
    {
      numSamples = 0;
      if (!sampleReady)      // if previous sample has been consumed
      {
        memcpy((void*)averages, bins, sizeof(averages));
        sampleReady = true;
      }
      memset(bins, 0, sizeof(bins));
    }
  }
}

void loop()
{
  while (!sampleReady) {}
  uint32_t oldTicks = ticks;
  
  if (digitalRead(encoderButtonPin) == LOW)
  {
    // Calibrate button pressed. We save the current phase detector outputs and subtract them from future results.
    // This lets us use the detector if the coil is slightly off-balance.
    // It would be better to everage several samples instead of taking just one.
    for (int i = 0; i < 4; ++i)
    {
      calib[i] = averages[i];
    }
    sampleReady = false;
    Serial.print("Calibrated: ");
    
    lcd.setCursor(0,0);
    lcd.print("Calibrating...  ");    
    for (int i = 0; i < 4; ++i)
    {
      Serial.write(' ');
      
      Serial.print(calib[i]);
    
    lcd.setCursor(0,1);    
    lcd.print(' ');    
    lcd.print(calib[4]); 
    lcd.print("        ");     
    }
    Serial.println();
  }
  else
  {  
    for (int i = 0; i < 4; ++i)
    {
      averages[i] -= calib[i];
    }
    const double f = 200.0;
    
    // Massage the results to eliminate sensitivity to the 3rd harmonic, and divide by 200
    double bin0 = (averages[0] + halfRoot2 * (averages[1] - averages[3]))/f;
    double bin1 = (averages[1] + halfRoot2 * (averages[0] + averages[2]))/f;
    double bin2 = (averages[2] + halfRoot2 * (averages[1] + averages[3]))/f;
    double bin3 = (averages[3] + halfRoot2 * (averages[2] - averages[0]))/f;
    sampleReady = false;          // we've finished reading the averages, so the ISR is free to overwrite them again

    double amp1 = sqrt((bin0 * bin0) + (bin2 * bin2));
    double amp2 = sqrt((bin1 * bin1) + (bin3 * bin3));
    double ampAverage = (amp1 + amp2)/2.0;
    
    // The ADC sample/hold takes place 2 clocks after the timer overflow
    double phase1 = atan2(bin0, bin2) * radiansToDegrees + 45.0;
    double phase2 = atan2(bin1, bin3) * radiansToDegrees;
  
    if (phase1 > phase2)
    {
      double temp = phase1;
      phase1 = phase2;
      phase2 = temp;
    }
    
    double phaseAverage = ((phase1 + phase2)/2.0) - phaseAdjust;
    if (phase2 - phase1 > 180.0)
    { 
      if (phaseAverage < 0.0)
      {
        phaseAverage += 180.0;
      }
      else
      {
        phaseAverage -= 180.0;
      }
    }
        
    // For diagnostic purposes, print the individual bin counts and the 2 indepedently-calculated gains and phases                                                        
    Serial.print(misses);
    Serial.write(' ');
    
    if (bin0 >= 0.0) Serial.write(' ');
    Serial.print(bin0, 2);
    Serial.write(' ');
    if (bin1 >= 0.0) Serial.write(' ');
    Serial.print(bin1, 2);
    Serial.write(' ');
    if (bin2 >= 0.0) Serial.write(' ');
    Serial.print(bin2, 2);
    Serial.write(' ');
    if (bin3 >= 0.0) Serial.write(' ');
    Serial.print(bin3, 2);
    Serial.print("    ");
    Serial.print(amp1, 2);
    Serial.write(' ');
    Serial.print(amp2, 2);
    Serial.write(' ');
    if (phase1 >= 0.0) Serial.write(' ');
    Serial.print(phase1, 2);
    Serial.write(' ');
    if (phase2 >= 0.0) Serial.write(' ');
    Serial.print(phase2, 2);
    Serial.print("    ");
    
    // Print the final amplitude and phase, which we use to decide what (if anything) we have found)
    if (ampAverage >= 0.0) Serial.write(' ');
    Serial.print(ampAverage, 1);
    Serial.write(' ');
        
        lcd.setCursor(0,0);
        lcd.print("          ");
        lcd.print(ampAverage);        
        lcd.setCursor(0,1);
        lbg.drawValue(ampAverage, max_ampAverage);

    if (phaseAverage >= 0.0) Serial.write(' ');
    Serial.print((int)phaseAverage);
    
    // Decide what we have found and tell the user
    if (ampAverage >= threshold)
    {
      // When held in line with the centre of the coil:
      // - non-ferrous metals give a negative phase shift, e.g. -90deg for thick copper or aluminium, a copper olive, -30deg for thin alumimium.
      // Ferrous metals give zero phase shift or a small positive phase shift.
      // So we'll say that anything with a phase shift below -20deg is non-ferrous.
      if (phaseAverage < -20.0)
      {
        Serial.print(" Non-ferrous");
        lcd.setCursor(0,0);        
        lcd.print("NonFerous ");      
     
      }
      else
      {
        Serial.print(" Ferrous");        
        lcd.setCursor(0,0);       
        lcd.print("Ferrous    ");                 
      }
      float temp = ampAverage;
              
       int thisPitch = map (temp, 10, 200, 100, 1500);
       tone(3, thisPitch,120);
       
      while (temp > threshold)
      {
        Serial.write('!');      
        temp -= (threshold/2);
      }
    }   
    Serial.println();
   
   }
  while (ticks - oldTicks < 8000)
  {
  }      
}

 

BOOM
BOOM аватар
Offline
Зарегистрирован: 14.11.2018

ksilius пишет:

Я правил так но у меня вылетает ошибка при компеляции.

Знаешь сколько ошибок компиляции бывает? Нет? Так выкладывай текстом - что за ошибка!

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

BOOM пишет:

ua6em пишет:

BOOM пишет:

Мошт #ifndef  твой "наоборот" ? ))

НЕА, так задумано, если библиотекаф  i2c НЕТУ КОМПИЛИРОВАТЬСЯ ПОД ОБЫЧНЫЕ

//#define LCDI2C

#ifndef LCDI2C
#include <LiquidCrystal.h> 
#include <LcdBarGraph.h> 
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
LcdBarGraph lbg(&lcd, 16, 0, 1);        // https://github.com/prampec/LcdBarGraph
#else
#include <LiquidCrystal_I2C.h>          // https://github.com/troublegum/liquidcrystal_i2c
#include <LcdBarGraph_I2C.h>  
LiquidCrystal_I2C lcd(0x27,16,2);
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1); 
#endif

 

Скетч использует 10702 байт (33%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 526 байт (25%) динамической памяти, оставляя 1522 байт для локальных переменных. Максимум: 2048 байт.

Не логично. Если ты объявляешь LCDI2C, то и подключай I2C-бибилиотеки. Так же по логике должно быть?...

а если не объявляешь )))
(ifndef)

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

BOOM пишет:

ksilius пишет:

Я правил так но у меня вылетает ошибка при компеляции.

Знаешь сколько ошибок компиляции бывает? Нет? Так выкладывай текстом - что за ошибка!

на правильных библиотеках нет там никаких ошибок

D:\ARDUINO\arduino-1.8.19\arduino-builder -dump-prefs -logger=machine -hardware D:\ARDUINO\arduino-1.8.19\hardware -hardware D:\ARDUINO\arduino-1.8.19\portable\packages -tools D:\ARDUINO\arduino-1.8.19\tools-builder -tools D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -tools D:\ARDUINO\arduino-1.8.19\portable\packages -built-in-libraries D:\ARDUINO\arduino-1.8.19\libraries -libraries D:\ARDUINO\arduino-1.8.19\portable\sketchbook\libraries -fqbn=arduino:avr:uno -ide-version=10819 -build-path C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167 -warnings=all -build-cache C:\Users\UA6EM\AppData\Local\Temp\arduino_cache_366554 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -verbose D:\ARDUINO\arduino-1.8.19\portable\sketchbook\2022\AVR\Metall_Detector_ORIG\Metall_Detector_ORIG.ino
D:\ARDUINO\arduino-1.8.19\arduino-builder -compile -logger=machine -hardware D:\ARDUINO\arduino-1.8.19\hardware -hardware D:\ARDUINO\arduino-1.8.19\portable\packages -tools D:\ARDUINO\arduino-1.8.19\tools-builder -tools D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -tools D:\ARDUINO\arduino-1.8.19\portable\packages -built-in-libraries D:\ARDUINO\arduino-1.8.19\libraries -libraries D:\ARDUINO\arduino-1.8.19\portable\sketchbook\libraries -fqbn=arduino:avr:uno -ide-version=10819 -build-path C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167 -warnings=all -build-cache C:\Users\UA6EM\AppData\Local\Temp\arduino_cache_366554 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=D:\ARDUINO\arduino-1.8.19\hardware\tools\avr -verbose D:\ARDUINO\arduino-1.8.19\portable\sketchbook\2022\AVR\Metall_Detector_ORIG\Metall_Detector_ORIG.ino
Using board 'uno' from platform in folder: D:\ARDUINO\arduino-1.8.19\hardware\arduino\avr
Using core 'arduino' from platform in folder: D:\ARDUINO\arduino-1.8.19\hardware\arduino\avr
Detecting libraries used...
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp" -o nul
Alternatives for LiquidCrystal_I2C.h: [liquidcrystal_i2c-master@1.0]
ResolveLibrary(LiquidCrystal_I2C.h)
  -> candidates: [liquidcrystal_i2c-master@1.0]
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp" -o nul
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
  -> candidates: [Wire@1.0]
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp" -o nul
Alternatives for LcdBarGraph_I2C.h: [LcdBarGraph-master@2.0.1]
ResolveLibrary(LcdBarGraph_I2C.h)
  -> candidates: [LcdBarGraph-master@2.0.1]
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp" -o nul
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "D:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master\\LiquidCrystal_I2C.cpp" -o nul
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "D:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src\\Wire.cpp" -o nul
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "D:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src\\utility\\twi.c" -o nul
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "D:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src\\LcdBarGraph.cpp" -o nul
Alternatives for LiquidCrystal.h: [LiquidCrystal@1.0.7]
ResolveLibrary(LiquidCrystal.h)
  -> candidates: [LiquidCrystal@1.0.7]
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\libraries\\LiquidCrystal\\src" "D:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src\\LcdBarGraph.cpp" -o nul
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\libraries\\LiquidCrystal\\src" "D:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src\\LcdBarGraph_I2C.cpp" -o nul
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\libraries\\LiquidCrystal\\src" "D:\\ARDUINO\\arduino-1.8.19\\libraries\\LiquidCrystal\\src\\LiquidCrystal.cpp" -o nul
Generating function prototypes...
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\libraries\\LiquidCrystal\\src" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp" -o "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"D:\\ARDUINO\\arduino-1.8.19\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Компиляция скетча...
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\liquidcrystal_i2c-master" "-ID:\\ARDUINO\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\portable\\sketchbook\\libraries\\LcdBarGraph-master\\src" "-ID:\\ARDUINO\\arduino-1.8.19\\libraries\\LiquidCrystal\\src" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp" -o "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp.o"
Compiling libraries...
Compiling library "liquidcrystal_i2c-master"
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\liquidcrystal_i2c-master\LiquidCrystal_I2C.cpp.o
Compiling library "Wire"
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\Wire\Wire.cpp.o
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\Wire\utility\twi.c.o
Compiling library "LcdBarGraph-master"
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\LcdBarGraph-master\LcdBarGraph_I2C.cpp.o
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\LcdBarGraph-master\LcdBarGraph.cpp.o
Compiling library "LiquidCrystal"
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\LiquidCrystal\LiquidCrystal.cpp.o
Compiling core...
Using precompiled core: C:\Users\UA6EM\AppData\Local\Temp\arduino_cache_366554\core\core_arduino_avr_uno_c47401c6bd8a389e878416c8e2c15e4a.a
Linking everything together...
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/Metall_Detector_ORIG.ino.elf" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\sketch\\Metall_Detector_ORIG.ino.cpp.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\libraries\\liquidcrystal_i2c-master\\LiquidCrystal_I2C.cpp.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\libraries\\Wire\\Wire.cpp.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\libraries\\Wire\\utility\\twi.c.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\libraries\\LcdBarGraph-master\\LcdBarGraph.cpp.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\libraries\\LcdBarGraph-master\\LcdBarGraph_I2C.cpp.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167\\libraries\\LiquidCrystal\\LiquidCrystal.cpp.o" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/..\\arduino_cache_366554\\core\\core_arduino_avr_uno_c47401c6bd8a389e878416c8e2c15e4a.a" "-LC:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167" -lm
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/Metall_Detector_ORIG.ino.elf" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/Metall_Detector_ORIG.ino.eep"
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/Metall_Detector_ORIG.ino.elf" "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/Metall_Detector_ORIG.ino.hex"
Используем библиотеку liquidcrystal_i2c-master версии 1.0 из папки: D:\ARDUINO\arduino-1.8.19\portable\sketchbook\libraries\liquidcrystal_i2c-master 
Используем библиотеку Wire версии 1.0 из папки: D:\ARDUINO\arduino-1.8.19\hardware\arduino\avr\libraries\Wire 
Используем библиотеку LcdBarGraph-master версии 2.0.1 из папки: D:\ARDUINO\arduino-1.8.19\portable\sketchbook\libraries\LcdBarGraph-master 
Используем библиотеку LiquidCrystal версии 1.0.7 из папки: D:\ARDUINO\arduino-1.8.19\libraries\LiquidCrystal 
"D:\\ARDUINO\\arduino-1.8.19\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\UA6EM\\AppData\\Local\\Temp\\arduino_build_464167/Metall_Detector_ORIG.ino.elf"
Скетч использует 11164 байт (34%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 588 байт (28%) динамической памяти, оставляя 1460 байт для локальных переменных. Максимум: 2048 байт.

 

ksilius
Offline
Зарегистрирован: 12.04.2022

Согласен, я готовлю:) но не в ардуино, яж говорю только верхушек нахватался.

 

ksilius
Offline
Зарегистрирован: 12.04.2022
Arduino: 1.8.19 (Windows 10), Плата:"Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D:\arduino_code\arduino_code.ino: In function 'void setup()':
 
arduino_code:85:18: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'
 
   lcd.begin(16, 2);// LCD 16X2
 
                  ^
 
In file included from D:\arduino_code\arduino_code.ino:27:0:
 
D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate: void LiquidCrystal_I2C::begin()
 
  void begin();
 
       ^~~~~
 
D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note:   candidate expects 0 arguments, 2 provided
 
D:\arduino_code\arduino_code.ino: In function 'void loop()':
 
arduino_code:290:9: error: 'lbg' was not declared in this scope
 
         lbg.drawValue(ampAverage, max_ampAverage);
 
         ^~~
 
D:\arduino_code\arduino_code.ino:290:9: note: suggested alternative: 'log'
 
         lbg.drawValue(ampAverage, max_ampAverage);
 
         ^~~
 
         log
 
arduino_code:290:35: error: 'max_ampAverage' was not declared in this scope
 
         lbg.drawValue(ampAverage, max_ampAverage);
 
                                   ^~~~~~~~~~~~~~
 
D:\arduino_code\arduino_code.ino:290:35: note: suggested alternative: 'ampAverage'
 
         lbg.drawValue(ampAverage, max_ampAverage);
 
                                   ^~~~~~~~~~~~~~
 
                                   ampAverage
 
exit status 1
 
no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'
 
 
 
Этот отчёт будет иметь больше информации с
включенной опцией Файл -> Настройки ->
"Показать подробный вывод во время компиляции"
 
ksilius
Offline
Зарегистрирован: 12.04.2022

Согласен долго я искал библиотеку что бы хоть холо ворл заработал.

ksilius
Offline
Зарегистрирован: 12.04.2022

Вод подробная ошибка.

Arduino: 1.8.19 (Windows 10), Плата:"Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"





















D:\Arduino\arduino-builder -dump-prefs -logger=machine -hardware D:\Arduino\hardware -tools D:\Arduino\tools-builder -tools D:\Arduino\hardware\tools\avr -built-in-libraries D:\Arduino\libraries -libraries C:\Users\Алексей\Documents\Arduino\libraries -fqbn=arduino:avr:pro:cpu=16MHzatmega328 -ide-version=10819 -build-path C:\Temp\arduino_build_851454 -warnings=none -build-cache C:\Temp\arduino_cache_715681 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=D:\Arduino\hardware\tools\avr -verbose D:\arduino_code\arduino_code.ino

D:\Arduino\arduino-builder -compile -logger=machine -hardware D:\Arduino\hardware -tools D:\Arduino\tools-builder -tools D:\Arduino\hardware\tools\avr -built-in-libraries D:\Arduino\libraries -libraries C:\Users\Алексей\Documents\Arduino\libraries -fqbn=arduino:avr:pro:cpu=16MHzatmega328 -ide-version=10819 -build-path C:\Temp\arduino_build_851454 -warnings=none -build-cache C:\Temp\arduino_cache_715681 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=D:\Arduino\hardware\tools\avr -verbose D:\arduino_code\arduino_code.ino

Using board 'pro' from platform in folder: D:\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: D:\Arduino\hardware\arduino\avr

Detecting libraries used...

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp" -o nul

Alternatives for Wire.h: [Wire@1.0]

ResolveLibrary(Wire.h)

  -> candidates: [Wire@1.0]

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp" -o nul

Alternatives for LiquidCrystal_I2C.h: [Arduino-LiquidCrystal-I2C-library-master]

ResolveLibrary(LiquidCrystal_I2C.h)

  -> candidates: [Arduino-LiquidCrystal-I2C-library-master]

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp" -o nul

Alternatives for EEPROM.h: [EEPROM@2.0]

ResolveLibrary(EEPROM.h)

  -> candidates: [EEPROM@2.0]

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp" -o nul

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "D:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src\\Wire.cpp" -o nul

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "D:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src\\utility\\twi.c" -o nul

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "D:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master\\LiquidCrystal_I2C.cpp" -o nul

Generating function prototypes...

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp" -o "C:\\Temp\\arduino_build_851454\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"D:\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Temp\\arduino_build_851454\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Компиляция скетча...

"D:\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-ID:\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-ID:\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp" -o "C:\\Temp\\arduino_build_851454\\sketch\\arduino_code.ino.cpp.o"

D:\arduino_code\arduino_code.ino: In function 'void setup()':

arduino_code:85:18: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'

   lcd.begin(16, 2);// LCD 16X2

                  ^

In file included from D:\arduino_code\arduino_code.ino:27:0:

D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate: void LiquidCrystal_I2C::begin()

  void begin();

       ^~~~~

D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note:   candidate expects 0 arguments, 2 provided

D:\arduino_code\arduino_code.ino: In function 'void loop()':

arduino_code:290:9: error: 'lbg' was not declared in this scope

         lbg.drawValue(ampAverage, max_ampAverage);

         ^~~

D:\arduino_code\arduino_code.ino:290:9: note: suggested alternative: 'log'

         lbg.drawValue(ampAverage, max_ampAverage);

         ^~~

         log

arduino_code:290:35: error: 'max_ampAverage' was not declared in this scope

         lbg.drawValue(ampAverage, max_ampAverage);

                                   ^~~~~~~~~~~~~~

D:\arduino_code\arduino_code.ino:290:35: note: suggested alternative: 'ampAverage'

         lbg.drawValue(ampAverage, max_ampAverage);

                                   ^~~~~~~~~~~~~~

                                   ampAverage

Используем библиотеку Wire версии 1.0 из папки: D:\Arduino\hardware\arduino\avr\libraries\Wire 

Используем библиотеку Arduino-LiquidCrystal-I2C-library-master в папке: D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master (legacy)

Используем библиотеку EEPROM версии 2.0 из папки: D:\Arduino\hardware\arduino\avr\libraries\EEPROM 

exit status 1

no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'

 

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

библиотеку LcdBarGraph.h тоже надо под I2C переписать

ksilius
Offline
Зарегистрирован: 12.04.2022

Как? наверное потому я и здесь со своей просьбой.

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

ksilius пишет:

Как? наверное потому я и здесь со своей просьбой.

обычно если сам не можешь заказываешь компетентный сервис )))

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

ksilius пишет:

Так научите это ... как сложно. Да и зачем нужна lcdbargraph.h если я собираюсь под i2c переписать код. С меня в контакте ардуинщик-бизнесмен запросил 1000 рублей это не вы случайно?

это не я и, ...так как ты просишь чтобы один неуч  учил второго неуча в этом случае ставка будет сильно выше, 4 часа 7 тыр )))
PS это не договор оферты...размышления вслух...

ksilius
Offline
Зарегистрирован: 12.04.2022

Ясно зря зашёл, ну всё равно спасибо, здоровья вам и удачи.

ksilius
Offline
Зарегистрирован: 12.04.2022

Ты богатый и очереди у тебя? Удачи в бизнесе.

Kakmyc
Offline
Зарегистрирован: 15.01.2018

ksilius пишет:

Ты богатый и очереди у тебя? Удачи в бизнесе.


А ты бедный и безмозглый.
Готовое купи, это дешевле.

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

ksilius пишет:

Ясно зря зашёл, ну всё равно спасибо, здоровья вам и удачи.

почему же зря, скетч тебе дали поправленный (заметь - безвозмездно), осталось решить или новый дисплей купить, или у этого выпаять контроллер или штуку заплатить тому, кто тебе предлагал ...это если по быстрому...
PS обычно хорошим тоном считается приводить ссылку на автора проекта

Не забываем, что не все библиотеки LCD_I2C  поддерживают необходимые нам функции, официальная - нет.
 

// unsupported API functions
void LiquidCrystal_I2C::off(){}
void LiquidCrystal_I2C::on(){}
void LiquidCrystal_I2C::setDelay (int cmdDelay,int charDelay) {}
uint8_t LiquidCrystal_I2C::status(){return 0;}
uint8_t LiquidCrystal_I2C::keypad (){return 0;}
uint8_t LiquidCrystal_I2C::init_bargraph(uint8_t graphtype){return 0;}
void LiquidCrystal_I2C::draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len,  uint8_t pixel_col_end){}
void LiquidCrystal_I2C::draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len,  uint8_t pixel_row_end){}
void LiquidCrystal_I2C::setContrast(uint8_t new_val){}


 

BOOM
BOOM аватар
Offline
Зарегистрирован: 14.11.2018

Проще гребенку снять ))))

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

BOOM пишет:

Проще гребенку снять ))))

проще новый дисплей купить )))