1602
- Войдите на сайт для отправки комментариев
Втр, 12/04/2022 - 14:11
Здравствуйте, хочу повторить схему металлоискателя на ардуино, есть такой код, в коде есть дисплей 1602 без адаптера I2C у меня адаптер запаян и не хочется отпаивать. Прошу помощи в прописке данного адаптера в этот код. Сам пробовал вставлять адаптер с адресом закоментировав при этом выводы на дисплей но вылазит ошибка.
001 | // Induction balance metal detector |
002 |
003 | // We run the CPU at 16MHz and the ADC clock at 1MHz. ADC resolution is reduced to 8 bits at this speed. |
004 |
005 | // Timer 1 is used to divide the system clock by about 256 to produce a 62.5kHz square wave. |
006 | // This is used to drive timer 0 and also to trigger ADC conversions. |
007 | // Timer 0 is used to divide the output of timer 1 by 8, giving a 7.8125kHz signal for driving the transmit coil. |
008 | // 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. |
009 | // 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 |
010 | // coil frequency. |
011 |
012 | // Timer 2 will be used to generate a tone for the earpiece or headset. |
013 |
014 | // Other division ratios for timer 1 are possible, from about 235 upwards. |
015 |
016 | // Wiring: |
017 | // Connect digital pin 4 (alias T0) to digital pin 9 |
018 | // Connect digital pin 5 through resistor to primary coil and tuning capacitor |
019 | // Connect output from receive amplifier to analog pin 0. Output of receive amplifier should be biased to about half of the analog reference. |
020 | // 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. |
021 | #include <LiquidCrystal.h> |
022 | #include <LcdBarGraph.h> |
023 | #define max_ampAverage 200 |
024 | LiquidCrystal lcd(6, 7, 10, 11, 12, 13); |
025 | LcdBarGraph lbg(&lcd, 16, 0, 1); |
026 |
027 | #define TIMER1_TOP (259) // can adjust this to fine-tune the frequency to get the coil tuned (see above) |
028 |
029 | #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 |
030 |
031 | // Digital pin definitions |
032 | // Digital pin 0 not used, however if we are using the serial port for debugging then it's serial input |
033 | const int debugTxPin = 1; // transmit pin reserved for debugging |
034 | const int encoderButtonPin = 2; // encoder button, also IN0 for waking up from sleep mode |
035 | const int earpiecePin = 3; // earpiece, aka OCR2B for tone generation |
036 | const int T0InputPin = 4; |
037 | const int coilDrivePin = 5; |
038 | const int LcdRsPin = 6; |
039 | const int LcdEnPin = 7; |
040 | const int LcdPowerPin = 8; // LCD power and backlight enable |
041 | const int T0OutputPin = 9; |
042 | const int lcdD4Pin = 10; |
043 | const int lcdD5Pin = 11; // pins 11-13 also used for ICSP |
044 | const int LcdD6Pin = 12; |
045 | const int LcdD7Pin = 13; |
046 |
047 | // Analog pin definitions |
048 | const int receiverInputPin = 0; |
049 | const int encoderAPin = A1; |
050 | const int encoderBpin = A2; |
051 | // Analog pins 3-5 not used |
052 |
053 | // Variables used only by the ISR |
054 | int16_t bins[4]; // bins used to accumulate ADC readings, one for each of the 4 phases |
055 | uint16_t numSamples = 0; |
056 | const uint16_t numSamplesToAverage = 1024; |
057 |
058 | // Variables used by the ISR and outside it |
059 | volatile int16_t averages[4]; // when we've accumulated enough readings in the bins, the ISR copies them to here and starts again |
060 | volatile uint32_t ticks = 0; // system tick counter for timekeeping |
061 | volatile bool sampleReady = false ; // indicates that the averages array has been updated |
062 |
063 | // Variables used only outside the ISR |
064 | int16_t calib[4]; // values (set during calibration) that we subtract from the averages |
065 |
066 | volatile uint8_t lastctr; |
067 | 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. |
068 |
069 | const double halfRoot2 = sqrt(0.5); |
070 | const double quarterPi = 3.1415927/4.0; |
071 | const double radiansToDegrees = 180.0/3.1415927; |
072 |
073 | // The ADC sample and hold occurs 2 ADC clocks (= 32 system clocks) after the timer 1 overflow flag is set. |
074 | // This introduces a slight phase error, which we adjust for in the calculations. |
075 | const float phaseAdjust = (45.0 * 32.0)/( float )(TIMER1_TOP + 1); |
076 |
077 | float threshold = 5.0; // lower = greater sensitivity. 10 is just about usable with a well-balanced coil. |
078 | // The user will be able to adjust this via a pot or rotary encoder. |
079 |
080 | void setup () |
081 | { |
082 | lcd.begin(16, 2); // LCD 16X2 |
083 | pinMode(encoderButtonPin, INPUT_PULLUP); |
084 | digitalWrite(T0OutputPin, LOW); |
085 | pinMode(T0OutputPin, OUTPUT); // pulse pin from timer 1 used to feed timer 0 |
086 | digitalWrite(coilDrivePin, LOW); |
087 | pinMode(coilDrivePin, OUTPUT); // timer 0 output, square wave to drive transmit coil |
088 | |
089 | cli(); |
090 | // Stop timer 0 which was set up by the Arduino core |
091 | TCCR0B = 0; // stop the timer |
092 | TIMSK0 = 0; // disable interrupt |
093 | TIFR0 = 0x07; // clear any pending interrupt |
094 | |
095 | // Set up ADC to trigger and read channel 0 on timer 1 overflow |
096 | #if USE_3V3_AREF |
097 | ADMUX = (1 << ADLAR); // use AREF pin (connected to 3.3V) as voltage reference, read pin A0, left-adjust result |
098 | #else |
099 | ADMUX = (1 << REFS0) | (1 << ADLAR); // use Avcc as voltage reference, read pin A0, left-adjust result |
100 | #endif |
101 | ADCSRB = (1 << ADTS2) | (1 << ADTS1); // auto-trigger ADC on timer/counter 1 overflow |
102 | ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | (1 << ADPS2); // enable adc, enable auto-trigger, prescaler = 16 (1MHz ADC clock) |
103 | DIDR0 = 1; |
104 |
105 | // Set up timer 1. |
106 | // Prescaler = 1, phase correct PWM mode, TOP = ICR1A |
107 | TCCR1A = (1 << COM1A1) | (1 << WGM11); |
108 | TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10); // CTC mode, prescaler = 1 |
109 | TCCR1C = 0; |
110 | OCR1AH = (TIMER1_TOP/2 >> 8); |
111 | OCR1AL = (TIMER1_TOP/2 & 0xFF); |
112 | ICR1H = (TIMER1_TOP >> 8); |
113 | ICR1L = (TIMER1_TOP & 0xFF); |
114 | TCNT1H = 0; |
115 | TCNT1L = 0; |
116 | TIFR1 = 0x07; // clear any pending interrupt |
117 | TIMSK1 = (1 << TOIE1); |
118 |
119 | // Set up timer 0 |
120 | // Clock source = T0, fast PWM mode, TOP (OCR0A) = 7, PWM output on OC0B |
121 | TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00); |
122 | TCCR0B = (1 << CS00) | (1 << CS01) | (1 << CS02) | (1 << WGM02); |
123 | OCR0A = 7; |
124 | OCR0B = 3; |
125 | TCNT0 = 0; |
126 | sei(); |
127 | |
128 | while (!sampleReady) {} // discard the first sample |
129 | misses = 0; |
130 | sampleReady = false ; |
131 | |
132 | Serial .begin(19200); |
133 | } |
134 |
135 | // Timer 0 overflow interrupt. This serves 2 purposes: |
136 | // 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. |
137 | // 2. It increments the tick counter, allowing is to do timekeeping. We get 62500 ticks/second. |
138 | // We now read the ADC in the timer interrupt routine instead of having a separate comversion complete interrupt. |
139 | ISR(TIMER1_OVF_vect) |
140 | { |
141 | ++ticks; |
142 | uint8_t ctr = TCNT0; |
143 | int16_t val = (int16_t)(uint16_t)ADCH; // only need to read most significant 8 bits |
144 | if (ctr != ((lastctr + 1) & 7)) |
145 | { |
146 | ++misses; |
147 | } |
148 | lastctr = ctr; |
149 | int16_t *p = &bins[ctr & 3]; |
150 | if (ctr < 4) |
151 | { |
152 | *p += (val); |
153 | if (*p > 15000) *p = 15000; |
154 | } |
155 | else |
156 | { |
157 | *p -= val; |
158 | if (*p < -15000) *p = -15000; |
159 | } |
160 | if (ctr == 7) |
161 | { |
162 | ++numSamples; |
163 | if (numSamples == numSamplesToAverage) |
164 | { |
165 | numSamples = 0; |
166 | if (!sampleReady) // if previous sample has been consumed |
167 | { |
168 | memcpy(( void *)averages, bins, sizeof (averages)); |
169 | sampleReady = true ; |
170 | } |
171 | memset(bins, 0, sizeof (bins)); |
172 | } |
173 | } |
174 | } |
175 |
176 | void loop () |
177 | { |
178 | while (!sampleReady) {} |
179 | uint32_t oldTicks = ticks; |
180 | |
181 | if (digitalRead(encoderButtonPin) == LOW) |
182 | { |
183 | // Calibrate button pressed. We save the current phase detector outputs and subtract them from future results. |
184 | // This lets us use the detector if the coil is slightly off-balance. |
185 | // It would be better to everage several samples instead of taking just one. |
186 | for ( int i = 0; i < 4; ++i) |
187 | { |
188 | calib[i] = averages[i]; |
189 | } |
190 | sampleReady = false ; |
191 | Serial .print( "Calibrated: " ); |
192 | |
193 | lcd.setCursor(0,0); |
194 | lcd.print( "Calibrating... " ); |
195 | for ( int i = 0; i < 4; ++i) |
196 | { |
197 | Serial .write( ' ' ); |
198 | |
199 | Serial .print(calib[i]); |
200 | |
201 | lcd.setCursor(0,1); |
202 | lcd.print( ' ' ); |
203 | lcd.print(calib[4]); |
204 | lcd.print( " " ); |
205 | } |
206 | Serial .println(); |
207 | } |
208 | else |
209 | { |
210 | for ( int i = 0; i < 4; ++i) |
211 | { |
212 | averages[i] -= calib[i]; |
213 | } |
214 | const double f = 200.0; |
215 | |
216 | // Massage the results to eliminate sensitivity to the 3rd harmonic, and divide by 200 |
217 | double bin0 = (averages[0] + halfRoot2 * (averages[1] - averages[3]))/f; |
218 | double bin1 = (averages[1] + halfRoot2 * (averages[0] + averages[2]))/f; |
219 | double bin2 = (averages[2] + halfRoot2 * (averages[1] + averages[3]))/f; |
220 | double bin3 = (averages[3] + halfRoot2 * (averages[2] - averages[0]))/f; |
221 | sampleReady = false ; // we've finished reading the averages, so the ISR is free to overwrite them again |
222 |
223 | double amp1 = sqrt((bin0 * bin0) + (bin2 * bin2)); |
224 | double amp2 = sqrt((bin1 * bin1) + (bin3 * bin3)); |
225 | double ampAverage = (amp1 + amp2)/2.0; |
226 | |
227 | // The ADC sample/hold takes place 2 clocks after the timer overflow |
228 | double phase1 = atan2(bin0, bin2) * radiansToDegrees + 45.0; |
229 | double phase2 = atan2(bin1, bin3) * radiansToDegrees; |
230 | |
231 | if (phase1 > phase2) |
232 | { |
233 | double temp = phase1; |
234 | phase1 = phase2; |
235 | phase2 = temp; |
236 | } |
237 | |
238 | double phaseAverage = ((phase1 + phase2)/2.0) - phaseAdjust; |
239 | if (phase2 - phase1 > 180.0) |
240 | { |
241 | if (phaseAverage < 0.0) |
242 | { |
243 | phaseAverage += 180.0; |
244 | } |
245 | else |
246 | { |
247 | phaseAverage -= 180.0; |
248 | } |
249 | } |
250 | |
251 | // For diagnostic purposes, print the individual bin counts and the 2 indepedently-calculated gains and phases |
252 | Serial .print(misses); |
253 | Serial .write( ' ' ); |
254 | |
255 | if (bin0 >= 0.0) Serial .write( ' ' ); |
256 | Serial .print(bin0, 2); |
257 | Serial .write( ' ' ); |
258 | if (bin1 >= 0.0) Serial .write( ' ' ); |
259 | Serial .print(bin1, 2); |
260 | Serial .write( ' ' ); |
261 | if (bin2 >= 0.0) Serial .write( ' ' ); |
262 | Serial .print(bin2, 2); |
263 | Serial .write( ' ' ); |
264 | if (bin3 >= 0.0) Serial .write( ' ' ); |
265 | Serial .print(bin3, 2); |
266 | Serial .print( " " ); |
267 | Serial .print(amp1, 2); |
268 | Serial .write( ' ' ); |
269 | Serial .print(amp2, 2); |
270 | Serial .write( ' ' ); |
271 | if (phase1 >= 0.0) Serial .write( ' ' ); |
272 | Serial .print(phase1, 2); |
273 | Serial .write( ' ' ); |
274 | if (phase2 >= 0.0) Serial .write( ' ' ); |
275 | Serial .print(phase2, 2); |
276 | Serial .print( " " ); |
277 | |
278 | // Print the final amplitude and phase, which we use to decide what (if anything) we have found) |
279 | if (ampAverage >= 0.0) Serial .write( ' ' ); |
280 | Serial .print(ampAverage, 1); |
281 | Serial .write( ' ' ); |
282 | |
283 | lcd.setCursor(0,0); |
284 | lcd.print( " " ); |
285 | lcd.print(ampAverage); |
286 | lcd.setCursor(0,1); |
287 | lbg.drawValue(ampAverage, max_ampAverage); |
288 |
289 | if (phaseAverage >= 0.0) Serial .write( ' ' ); |
290 | Serial .print(( int )phaseAverage); |
291 | |
292 | // Decide what we have found and tell the user |
293 | if (ampAverage >= threshold) |
294 | { |
295 | // When held in line with the centre of the coil: |
296 | // - non-ferrous metals give a negative phase shift, e.g. -90deg for thick copper or aluminium, a copper olive, -30deg for thin alumimium. |
297 | // Ferrous metals give zero phase shift or a small positive phase shift. |
298 | // So we'll say that anything with a phase shift below -20deg is non-ferrous. |
299 | if (phaseAverage < -20.0) |
300 | { |
301 | Serial .print( " Non-ferrous" ); |
302 | lcd.setCursor(0,0); |
303 | lcd.print( "NonFerous " ); |
304 | |
305 | } |
306 | else |
307 | { |
308 | Serial .print( " Ferrous" ); |
309 | lcd.setCursor(0,0); |
310 | lcd.print( "Ferrous " ); |
311 | } |
312 | float temp = ampAverage; |
313 | |
314 | int thisPitch = map (temp, 10, 200, 100, 1500); |
315 | tone(3, thisPitch,120); |
316 | |
317 | while (temp > threshold) |
318 | { |
319 | Serial .write( '!' ); |
320 | temp -= (threshold/2); |
321 | } |
322 | } |
323 | Serial .println(); |
324 | |
325 | } |
326 | while (ticks - oldTicks < 8000) |
327 | { |
328 | } |
329 | } |
Вместо библиотеки LiquidCrystal используйте библиотеку LiquidCrystal_I2C
Все библиотеки на месте и работаю проверено на хало ворлд. Я может чуть знаю что такое ардуино верхушек нахватался но осоцилограф на ардуино спаял.
Все библиотеки на месте и работаю проверено на хало ворлд.
если "все библиотеки на месте и работают" - в чем тогда вопрос?
Еще раз - Вместо библиотеки LiquidCrystal используйте библиотеку LiquidCrystal_I2C
Или буковки I2C в конце названия ни о чем не говорят?
Еще раз - Вместо библиотеки LiquidCrystal используйте библиотеку LiquidCrystal_I2C
Или буковки I2C в конце названия ни о чем не говорят?
Этого мало, библиотеку LcdBarGraph.h тоже надо под I2C переписать, это не сложно, но ведь надо )))
как-то так:
001
// Induction balance metal detector
002
003
// We run the CPU at 16MHz and the ADC clock at 1MHz. ADC resolution is reduced to 8 bits at this speed.
004
005
// Timer 1 is used to divide the system clock by about 256 to produce a 62.5kHz square wave.
006
// This is used to drive timer 0 and also to trigger ADC conversions.
007
// Timer 0 is used to divide the output of timer 1 by 8, giving a 7.8125kHz signal for driving the transmit coil.
008
// 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.
009
// 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
010
// coil frequency.
011
012
// Timer 2 will be used to generate a tone for the earpiece or headset.
013
014
// Other division ratios for timer 1 are possible, from about 235 upwards.
015
016
// Wiring:
017
// Connect digital pin 4 (alias T0) to digital pin 9
018
// Connect digital pin 5 through resistor to primary coil and tuning capacitor
019
// Connect output from receive amplifier to analog pin 0. Output of receive amplifier should be biased to about half of the analog reference.
020
// 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.
021
022
#define LCDI2C
023
024
#ifndef LCDI2C
025
#include <LiquidCrystal.h>
026
#include <LcdBarGraph.h>
027
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
028
LcdBarGraph lbg(&lcd, 16, 0, 1);
// <a href="https://github.com/prampec/LcdBarGraph" rel="nofollow">https://github.com/prampec/LcdBarGraph</a>
029
#else
030
#include <LiquidCrystal_I2C.h> // <a href="https://github.com/troublegum/liquidcrystal_i2c" rel="nofollow">https://github.com/troublegum/liquidcrystal_i2c</a>
031
#include <LcdBarGraph_I2C.h>
032
LiquidCrystal_I2C lcd(0x27,16,2);
033
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1);
034
#endif
035
036
037
#define max_ampAverage 200
038
039
#define TIMER1_TOP (259) // can adjust this to fine-tune the frequency to get the coil tuned (see above)
040
041
#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
042
043
// Digital pin definitions
044
// Digital pin 0 not used, however if we are using the serial port for debugging then it's serial input
045
const
int
debugTxPin = 1;
// transmit pin reserved for debugging
046
const
int
encoderButtonPin = 2;
// encoder button, also IN0 for waking up from sleep mode
047
const
int
earpiecePin = 3;
// earpiece, aka OCR2B for tone generation
048
const
int
T0InputPin = 4;
049
const
int
coilDrivePin = 5;
050
const
int
LcdRsPin = 6;
051
const
int
LcdEnPin = 7;
052
const
int
LcdPowerPin = 8;
// LCD power and backlight enable
053
const
int
T0OutputPin = 9;
054
const
int
lcdD4Pin = 10;
055
const
int
lcdD5Pin = 11;
// pins 11-13 also used for ICSP
056
const
int
LcdD6Pin = 12;
057
const
int
LcdD7Pin = 13;
058
059
// Analog pin definitions
060
const
int
receiverInputPin = 0;
061
const
int
encoderAPin = A1;
062
const
int
encoderBpin = A2;
063
// Analog pins 3-5 not used
064
065
// Variables used only by the ISR
066
int16_t bins[4];
// bins used to accumulate ADC readings, one for each of the 4 phases
067
uint16_t numSamples = 0;
068
const
uint16_t numSamplesToAverage = 1024;
069
070
// Variables used by the ISR and outside it
071
volatile int16_t averages[4];
// when we've accumulated enough readings in the bins, the ISR copies them to here and starts again
072
volatile uint32_t ticks = 0;
// system tick counter for timekeeping
073
volatile
bool
sampleReady =
false
;
// indicates that the averages array has been updated
074
075
// Variables used only outside the ISR
076
int16_t calib[4];
// values (set during calibration) that we subtract from the averages
077
078
volatile uint8_t lastctr;
079
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.
080
081
const
double
halfRoot2 = sqrt(0.5);
082
const
double
quarterPi = 3.1415927/4.0;
083
const
double
radiansToDegrees = 180.0/3.1415927;
084
085
// The ADC sample and hold occurs 2 ADC clocks (= 32 system clocks) after the timer 1 overflow flag is set.
086
// This introduces a slight phase error, which we adjust for in the calculations.
087
const
float
phaseAdjust = (45.0 * 32.0)/(
float
)(TIMER1_TOP + 1);
088
089
float
threshold = 5.0;
// lower = greater sensitivity. 10 is just about usable with a well-balanced coil.
090
// The user will be able to adjust this via a pot or rotary encoder.
091
092
void
setup
()
093
{
094
lcd.begin(16, 2);
// LCD 16X2
095
pinMode(encoderButtonPin, INPUT_PULLUP);
096
digitalWrite(T0OutputPin, LOW);
097
pinMode(T0OutputPin, OUTPUT);
// pulse pin from timer 1 used to feed timer 0
098
digitalWrite(coilDrivePin, LOW);
099
pinMode(coilDrivePin, OUTPUT);
// timer 0 output, square wave to drive transmit coil
100
101
cli();
102
// Stop timer 0 which was set up by the Arduino core
103
TCCR0B = 0;
// stop the timer
104
TIMSK0 = 0;
// disable interrupt
105
TIFR0 = 0x07;
// clear any pending interrupt
106
107
// Set up ADC to trigger and read channel 0 on timer 1 overflow
108
#if USE_3V3_AREF
109
ADMUX = (1 << ADLAR);
// use AREF pin (connected to 3.3V) as voltage reference, read pin A0, left-adjust result
110
#else
111
ADMUX = (1 << REFS0) | (1 << ADLAR);
// use Avcc as voltage reference, read pin A0, left-adjust result
112
#endif
113
ADCSRB = (1 << ADTS2) | (1 << ADTS1);
// auto-trigger ADC on timer/counter 1 overflow
114
ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | (1 << ADPS2);
// enable adc, enable auto-trigger, prescaler = 16 (1MHz ADC clock)
115
DIDR0 = 1;
116
117
// Set up timer 1.
118
// Prescaler = 1, phase correct PWM mode, TOP = ICR1A
119
TCCR1A = (1 << COM1A1) | (1 << WGM11);
120
TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10);
// CTC mode, prescaler = 1
121
TCCR1C = 0;
122
OCR1AH = (TIMER1_TOP/2 >> 8);
123
OCR1AL = (TIMER1_TOP/2 & 0xFF);
124
ICR1H = (TIMER1_TOP >> 8);
125
ICR1L = (TIMER1_TOP & 0xFF);
126
TCNT1H = 0;
127
TCNT1L = 0;
128
TIFR1 = 0x07;
// clear any pending interrupt
129
TIMSK1 = (1 << TOIE1);
130
131
// Set up timer 0
132
// Clock source = T0, fast PWM mode, TOP (OCR0A) = 7, PWM output on OC0B
133
TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);
134
TCCR0B = (1 << CS00) | (1 << CS01) | (1 << CS02) | (1 << WGM02);
135
OCR0A = 7;
136
OCR0B = 3;
137
TCNT0 = 0;
138
sei();
139
140
while
(!sampleReady) {}
// discard the first sample
141
misses = 0;
142
sampleReady =
false
;
143
144
Serial
.begin(19200);
145
}
146
147
// Timer 0 overflow interrupt. This serves 2 purposes:
148
// 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.
149
// 2. It increments the tick counter, allowing is to do timekeeping. We get 62500 ticks/second.
150
// We now read the ADC in the timer interrupt routine instead of having a separate comversion complete interrupt.
151
ISR(TIMER1_OVF_vect)
152
{
153
++ticks;
154
uint8_t ctr = TCNT0;
155
int16_t val = (int16_t)(uint16_t)ADCH;
// only need to read most significant 8 bits
156
if
(ctr != ((lastctr + 1) & 7))
157
{
158
++misses;
159
}
160
lastctr = ctr;
161
int16_t *p = &bins[ctr & 3];
162
if
(ctr < 4)
163
{
164
*p += (val);
165
if
(*p > 15000) *p = 15000;
166
}
167
else
168
{
169
*p -= val;
170
if
(*p < -15000) *p = -15000;
171
}
172
if
(ctr == 7)
173
{
174
++numSamples;
175
if
(numSamples == numSamplesToAverage)
176
{
177
numSamples = 0;
178
if
(!sampleReady)
// if previous sample has been consumed
179
{
180
memcpy((
void
*)averages, bins,
sizeof
(averages));
181
sampleReady =
true
;
182
}
183
memset(bins, 0,
sizeof
(bins));
184
}
185
}
186
}
187
188
void
loop
()
189
{
190
while
(!sampleReady) {}
191
uint32_t oldTicks = ticks;
192
193
if
(digitalRead(encoderButtonPin) == LOW)
194
{
195
// Calibrate button pressed. We save the current phase detector outputs and subtract them from future results.
196
// This lets us use the detector if the coil is slightly off-balance.
197
// It would be better to everage several samples instead of taking just one.
198
for
(
int
i = 0; i < 4; ++i)
199
{
200
calib[i] = averages[i];
201
}
202
sampleReady =
false
;
203
Serial
.print(
"Calibrated: "
);
204
205
lcd.setCursor(0,0);
206
lcd.print(
"Calibrating... "
);
207
for
(
int
i = 0; i < 4; ++i)
208
{
209
Serial
.write(
' '
);
210
211
Serial
.print(calib[i]);
212
213
lcd.setCursor(0,1);
214
lcd.print(
' '
);
215
lcd.print(calib[4]);
216
lcd.print(
" "
);
217
}
218
Serial
.println();
219
}
220
else
221
{
222
for
(
int
i = 0; i < 4; ++i)
223
{
224
averages[i] -= calib[i];
225
}
226
const
double
f = 200.0;
227
228
// Massage the results to eliminate sensitivity to the 3rd harmonic, and divide by 200
229
double
bin0 = (averages[0] + halfRoot2 * (averages[1] - averages[3]))/f;
230
double
bin1 = (averages[1] + halfRoot2 * (averages[0] + averages[2]))/f;
231
double
bin2 = (averages[2] + halfRoot2 * (averages[1] + averages[3]))/f;
232
double
bin3 = (averages[3] + halfRoot2 * (averages[2] - averages[0]))/f;
233
sampleReady =
false
;
// we've finished reading the averages, so the ISR is free to overwrite them again
234
235
double
amp1 = sqrt((bin0 * bin0) + (bin2 * bin2));
236
double
amp2 = sqrt((bin1 * bin1) + (bin3 * bin3));
237
double
ampAverage = (amp1 + amp2)/2.0;
238
239
// The ADC sample/hold takes place 2 clocks after the timer overflow
240
double
phase1 = atan2(bin0, bin2) * radiansToDegrees + 45.0;
241
double
phase2 = atan2(bin1, bin3) * radiansToDegrees;
242
243
if
(phase1 > phase2)
244
{
245
double
temp = phase1;
246
phase1 = phase2;
247
phase2 = temp;
248
}
249
250
double
phaseAverage = ((phase1 + phase2)/2.0) - phaseAdjust;
251
if
(phase2 - phase1 > 180.0)
252
{
253
if
(phaseAverage < 0.0)
254
{
255
phaseAverage += 180.0;
256
}
257
else
258
{
259
phaseAverage -= 180.0;
260
}
261
}
262
263
// For diagnostic purposes, print the individual bin counts and the 2 indepedently-calculated gains and phases
264
Serial
.print(misses);
265
Serial
.write(
' '
);
266
267
if
(bin0 >= 0.0)
Serial
.write(
' '
);
268
Serial
.print(bin0, 2);
269
Serial
.write(
' '
);
270
if
(bin1 >= 0.0)
Serial
.write(
' '
);
271
Serial
.print(bin1, 2);
272
Serial
.write(
' '
);
273
if
(bin2 >= 0.0)
Serial
.write(
' '
);
274
Serial
.print(bin2, 2);
275
Serial
.write(
' '
);
276
if
(bin3 >= 0.0)
Serial
.write(
' '
);
277
Serial
.print(bin3, 2);
278
Serial
.print(
" "
);
279
Serial
.print(amp1, 2);
280
Serial
.write(
' '
);
281
Serial
.print(amp2, 2);
282
Serial
.write(
' '
);
283
if
(phase1 >= 0.0)
Serial
.write(
' '
);
284
Serial
.print(phase1, 2);
285
Serial
.write(
' '
);
286
if
(phase2 >= 0.0)
Serial
.write(
' '
);
287
Serial
.print(phase2, 2);
288
Serial
.print(
" "
);
289
290
// Print the final amplitude and phase, which we use to decide what (if anything) we have found)
291
if
(ampAverage >= 0.0)
Serial
.write(
' '
);
292
Serial
.print(ampAverage, 1);
293
Serial
.write(
' '
);
294
295
lcd.setCursor(0,0);
296
lcd.print(
" "
);
297
lcd.print(ampAverage);
298
lcd.setCursor(0,1);
299
lbg.drawValue(ampAverage, max_ampAverage);
300
301
if
(phaseAverage >= 0.0)
Serial
.write(
' '
);
302
Serial
.print((
int
)phaseAverage);
303
304
// Decide what we have found and tell the user
305
if
(ampAverage >= threshold)
306
{
307
// When held in line with the centre of the coil:
308
// - non-ferrous metals give a negative phase shift, e.g. -90deg for thick copper or aluminium, a copper olive, -30deg for thin alumimium.
309
// Ferrous metals give zero phase shift or a small positive phase shift.
310
// So we'll say that anything with a phase shift below -20deg is non-ferrous.
311
if
(phaseAverage < -20.0)
312
{
313
Serial
.print(
" Non-ferrous"
);
314
lcd.setCursor(0,0);
315
lcd.print(
"NonFerous "
);
316
317
}
318
else
319
{
320
Serial
.print(
" Ferrous"
);
321
lcd.setCursor(0,0);
322
lcd.print(
"Ferrous "
);
323
}
324
float
temp = ampAverage;
325
326
int
thisPitch = map (temp, 10, 200, 100, 1500);
327
tone(3, thisPitch,120);
328
329
while
(temp > threshold)
330
{
331
Serial
.write(
'!'
);
332
temp -= (threshold/2);
333
}
334
}
335
Serial
.println();
336
337
}
338
while
(ticks - oldTicks < 8000)
339
{
340
}
341
}
1
Скетч использует 11164 байт (34%) памяти устройства. Всего доступно 32256 байт.
2
Глобальные переменные используют 588 байт (28%) динамической памяти, оставляя 1460 байт для локальных переменных. Максимум: 2048 байт.
Мошт #ifndef твой "наоборот" ? ))
Мошт #ifndef твой "наоборот" ? ))
НЕА, так задумано, если библиотекаф i2c НЕТУ КОМПИЛИРОВАТЬСЯ ПОД ОБЫЧНЫЕ
01
//#define LCDI2C
02
03
#ifndef LCDI2C
04
#include <LiquidCrystal.h>
05
#include <LcdBarGraph.h>
06
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
07
LcdBarGraph lbg(&lcd, 16, 0, 1);
// <a href="https://github.com/prampec/LcdBarGraph" title="https://github.com/prampec/LcdBarGraph" rel="nofollow">https://github.com/prampec/LcdBarGraph</a>
08
#else
09
#include <LiquidCrystal_I2C.h> // <a href="https://github.com/troublegum/liquidcrystal_i2c" title="https://github.com/troublegum/liquidcrystal_i2c" rel="nofollow">https://github.com/troublegum/liquidcrystal_i2c</a>
10
#include <LcdBarGraph_I2C.h>
11
LiquidCrystal_I2C lcd(0x27,16,2);
12
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1);
13
#endif
1
Скетч использует 10702 байт (33%) памяти устройства. Всего доступно 32256 байт.
2
Глобальные переменные используют 526 байт (25%) динамической памяти, оставляя 1522 байт для локальных переменных. Максимум: 2048 байт.
В холоу ворде работают в этом коде видимо нет.
В холоу ворде работают в этом коде видимо нет.
блюда надо уметь готовить )))
Мошт #ifndef твой "наоборот" ? ))
НЕА, так задумано, если библиотекаф i2c НЕТУ КОМПИЛИРОВАТЬСЯ ПОД ОБЫЧНЫЕ
01
//#define LCDI2C
02
03
#ifndef LCDI2C
04
#include <LiquidCrystal.h>
05
#include <LcdBarGraph.h>
06
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
07
LcdBarGraph lbg(&lcd, 16, 0, 1);
// <a href="https://github.com/prampec/LcdBarGraph" title="https://github.com/prampec/LcdBarGraph" rel="nofollow">https://github.com/prampec/LcdBarGraph</a>
08
#else
09
#include <LiquidCrystal_I2C.h> // <a href="https://github.com/troublegum/liquidcrystal_i2c" title="https://github.com/troublegum/liquidcrystal_i2c" rel="nofollow">https://github.com/troublegum/liquidcrystal_i2c</a>
10
#include <LcdBarGraph_I2C.h>
11
LiquidCrystal_I2C lcd(0x27,16,2);
12
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1);
13
#endif
1
Скетч использует 10702 байт (33%) памяти устройства. Всего доступно 32256 байт.
2
Глобальные переменные используют 526 байт (25%) динамической памяти, оставляя 1522 байт для локальных переменных. Максимум: 2048 байт.
Не логично. Если ты объявляешь LCDI2C, то и подключай I2C-бибилиотеки. Так же по логике должно быть?...
Я правил так но у меня вылетает ошибка при компеляции.
001
// Induction balance metal detector
002
003
// We run the CPU at 16MHz and the ADC clock at 1MHz. ADC resolution is reduced to 8 bits at this speed.
004
005
// Timer 1 is used to divide the system clock by about 256 to produce a 62.5kHz square wave.
006
// This is used to drive timer 0 and also to trigger ADC conversions.
007
// Timer 0 is used to divide the output of timer 1 by 8, giving a 7.8125kHz signal for driving the transmit coil.
008
// 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.
009
// 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
010
// coil frequency.
011
012
// Timer 2 will be used to generate a tone for the earpiece or headset.
013
014
// Other division ratios for timer 1 are possible, from about 235 upwards.
015
016
// Wiring:
017
// Connect digital pin 4 (alias T0) to digital pin 9
018
// Connect digital pin 5 through resistor to primary coil and tuning capacitor
019
// Connect output from receive amplifier to analog pin 0. Output of receive amplifier should be biased to about half of the analog reference.
020
// 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.
021
//#include <LiquidCrystal.h>
022
//#include <LcdBarGraph.h>
023
//#define max_ampAverage 200
024
//LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
025
//LcdBarGraph lbg(&lcd, 16, 0, 1);
026
#include <Wire.h>
027
#include <LiquidCrystal_I2C.h>
028
#include <EEPROM.h>
029
LiquidCrystal_I2C lcd(0x27,16,2);
//0x20 ; ox27 ; 0x3F
030
#define TIMER1_TOP (259) // can adjust this to fine-tune the frequency to get the coil tuned (see above)
031
032
#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
033
034
// Digital pin definitions
035
// Digital pin 0 not used, however if we are using the serial port for debugging then it's serial input
036
const
int
debugTxPin = 1;
// transmit pin reserved for debugging
037
const
int
encoderButtonPin = 2;
// encoder button, also IN0 for waking up from sleep mode
038
const
int
earpiecePin = 3;
// earpiece, aka OCR2B for tone generation
039
const
int
T0InputPin = 4;
040
const
int
coilDrivePin = 5;
041
const
int
LcdRsPin = 6;
042
const
int
LcdEnPin = 7;
043
const
int
LcdPowerPin = 8;
// LCD power and backlight enable
044
const
int
T0OutputPin = 9;
045
const
int
lcdD4Pin = 10;
046
const
int
lcdD5Pin = 11;
// pins 11-13 also used for ICSP
047
const
int
LcdD6Pin = 12;
048
const
int
LcdD7Pin = 13;
049
050
// Analog pin definitions
051
const
int
receiverInputPin = 0;
052
const
int
encoderAPin = A1;
053
const
int
encoderBpin = A2;
054
// Analog pins 3-5 not used
055
056
// Variables used only by the ISR
057
int16_t bins[4];
// bins used to accumulate ADC readings, one for each of the 4 phases
058
uint16_t numSamples = 0;
059
const
uint16_t numSamplesToAverage = 1024;
060
061
// Variables used by the ISR and outside it
062
volatile int16_t averages[4];
// when we've accumulated enough readings in the bins, the ISR copies them to here and starts again
063
volatile uint32_t ticks = 0;
// system tick counter for timekeeping
064
volatile
bool
sampleReady =
false
;
// indicates that the averages array has been updated
065
066
// Variables used only outside the ISR
067
int16_t calib[4];
// values (set during calibration) that we subtract from the averages
068
069
volatile uint8_t lastctr;
070
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.
071
072
const
double
halfRoot2 = sqrt(0.5);
073
const
double
quarterPi = 3.1415927/4.0;
074
const
double
radiansToDegrees = 180.0/3.1415927;
075
076
// The ADC sample and hold occurs 2 ADC clocks (= 32 system clocks) after the timer 1 overflow flag is set.
077
// This introduces a slight phase error, which we adjust for in the calculations.
078
const
float
phaseAdjust = (45.0 * 32.0)/(
float
)(TIMER1_TOP + 1);
079
080
float
threshold = 5.0;
// lower = greater sensitivity. 10 is just about usable with a well-balanced coil.
081
// The user will be able to adjust this via a pot or rotary encoder.
082
083
void
setup
()
084
{
085
lcd.begin(16, 2);
// LCD 16X2
086
pinMode(encoderButtonPin, INPUT_PULLUP);
087
digitalWrite(T0OutputPin, LOW);
088
pinMode(T0OutputPin, OUTPUT);
// pulse pin from timer 1 used to feed timer 0
089
digitalWrite(coilDrivePin, LOW);
090
pinMode(coilDrivePin, OUTPUT);
// timer 0 output, square wave to drive transmit coil
091
092
cli();
093
// Stop timer 0 which was set up by the Arduino core
094
TCCR0B = 0;
// stop the timer
095
TIMSK0 = 0;
// disable interrupt
096
TIFR0 = 0x07;
// clear any pending interrupt
097
098
// Set up ADC to trigger and read channel 0 on timer 1 overflow
099
#if USE_3V3_AREF
100
ADMUX = (1 << ADLAR);
// use AREF pin (connected to 3.3V) as voltage reference, read pin A0, left-adjust result
101
#else
102
ADMUX = (1 << REFS0) | (1 << ADLAR);
// use Avcc as voltage reference, read pin A0, left-adjust result
103
#endif
104
ADCSRB = (1 << ADTS2) | (1 << ADTS1);
// auto-trigger ADC on timer/counter 1 overflow
105
ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | (1 << ADPS2);
// enable adc, enable auto-trigger, prescaler = 16 (1MHz ADC clock)
106
DIDR0 = 1;
107
108
// Set up timer 1.
109
// Prescaler = 1, phase correct PWM mode, TOP = ICR1A
110
TCCR1A = (1 << COM1A1) | (1 << WGM11);
111
TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10);
// CTC mode, prescaler = 1
112
TCCR1C = 0;
113
OCR1AH = (TIMER1_TOP/2 >> 8);
114
OCR1AL = (TIMER1_TOP/2 & 0xFF);
115
ICR1H = (TIMER1_TOP >> 8);
116
ICR1L = (TIMER1_TOP & 0xFF);
117
TCNT1H = 0;
118
TCNT1L = 0;
119
TIFR1 = 0x07;
// clear any pending interrupt
120
TIMSK1 = (1 << TOIE1);
121
122
// Set up timer 0
123
// Clock source = T0, fast PWM mode, TOP (OCR0A) = 7, PWM output on OC0B
124
TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);
125
TCCR0B = (1 << CS00) | (1 << CS01) | (1 << CS02) | (1 << WGM02);
126
OCR0A = 7;
127
OCR0B = 3;
128
TCNT0 = 0;
129
sei();
130
131
while
(!sampleReady) {}
// discard the first sample
132
misses = 0;
133
sampleReady =
false
;
134
135
Serial
.begin(19200);
136
}
137
138
// Timer 0 overflow interrupt. This serves 2 purposes:
139
// 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.
140
// 2. It increments the tick counter, allowing is to do timekeeping. We get 62500 ticks/second.
141
// We now read the ADC in the timer interrupt routine instead of having a separate comversion complete interrupt.
142
ISR(TIMER1_OVF_vect)
143
{
144
++ticks;
145
uint8_t ctr = TCNT0;
146
int16_t val = (int16_t)(uint16_t)ADCH;
// only need to read most significant 8 bits
147
if
(ctr != ((lastctr + 1) & 7))
148
{
149
++misses;
150
}
151
lastctr = ctr;
152
int16_t *p = &bins[ctr & 3];
153
if
(ctr < 4)
154
{
155
*p += (val);
156
if
(*p > 15000) *p = 15000;
157
}
158
else
159
{
160
*p -= val;
161
if
(*p < -15000) *p = -15000;
162
}
163
if
(ctr == 7)
164
{
165
++numSamples;
166
if
(numSamples == numSamplesToAverage)
167
{
168
numSamples = 0;
169
if
(!sampleReady)
// if previous sample has been consumed
170
{
171
memcpy((
void
*)averages, bins,
sizeof
(averages));
172
sampleReady =
true
;
173
}
174
memset(bins, 0,
sizeof
(bins));
175
}
176
}
177
}
178
179
void
loop
()
180
{
181
while
(!sampleReady) {}
182
uint32_t oldTicks = ticks;
183
184
if
(digitalRead(encoderButtonPin) == LOW)
185
{
186
// Calibrate button pressed. We save the current phase detector outputs and subtract them from future results.
187
// This lets us use the detector if the coil is slightly off-balance.
188
// It would be better to everage several samples instead of taking just one.
189
for
(
int
i = 0; i < 4; ++i)
190
{
191
calib[i] = averages[i];
192
}
193
sampleReady =
false
;
194
Serial
.print(
"Calibrated: "
);
195
196
lcd.setCursor(0,0);
197
lcd.print(
"Calibrating... "
);
198
for
(
int
i = 0; i < 4; ++i)
199
{
200
Serial
.write(
' '
);
201
202
Serial
.print(calib[i]);
203
204
lcd.setCursor(0,1);
205
lcd.print(
' '
);
206
lcd.print(calib[4]);
207
lcd.print(
" "
);
208
}
209
Serial
.println();
210
}
211
else
212
{
213
for
(
int
i = 0; i < 4; ++i)
214
{
215
averages[i] -= calib[i];
216
}
217
const
double
f = 200.0;
218
219
// Massage the results to eliminate sensitivity to the 3rd harmonic, and divide by 200
220
double
bin0 = (averages[0] + halfRoot2 * (averages[1] - averages[3]))/f;
221
double
bin1 = (averages[1] + halfRoot2 * (averages[0] + averages[2]))/f;
222
double
bin2 = (averages[2] + halfRoot2 * (averages[1] + averages[3]))/f;
223
double
bin3 = (averages[3] + halfRoot2 * (averages[2] - averages[0]))/f;
224
sampleReady =
false
;
// we've finished reading the averages, so the ISR is free to overwrite them again
225
226
double
amp1 = sqrt((bin0 * bin0) + (bin2 * bin2));
227
double
amp2 = sqrt((bin1 * bin1) + (bin3 * bin3));
228
double
ampAverage = (amp1 + amp2)/2.0;
229
230
// The ADC sample/hold takes place 2 clocks after the timer overflow
231
double
phase1 = atan2(bin0, bin2) * radiansToDegrees + 45.0;
232
double
phase2 = atan2(bin1, bin3) * radiansToDegrees;
233
234
if
(phase1 > phase2)
235
{
236
double
temp = phase1;
237
phase1 = phase2;
238
phase2 = temp;
239
}
240
241
double
phaseAverage = ((phase1 + phase2)/2.0) - phaseAdjust;
242
if
(phase2 - phase1 > 180.0)
243
{
244
if
(phaseAverage < 0.0)
245
{
246
phaseAverage += 180.0;
247
}
248
else
249
{
250
phaseAverage -= 180.0;
251
}
252
}
253
254
// For diagnostic purposes, print the individual bin counts and the 2 indepedently-calculated gains and phases
255
Serial
.print(misses);
256
Serial
.write(
' '
);
257
258
if
(bin0 >= 0.0)
Serial
.write(
' '
);
259
Serial
.print(bin0, 2);
260
Serial
.write(
' '
);
261
if
(bin1 >= 0.0)
Serial
.write(
' '
);
262
Serial
.print(bin1, 2);
263
Serial
.write(
' '
);
264
if
(bin2 >= 0.0)
Serial
.write(
' '
);
265
Serial
.print(bin2, 2);
266
Serial
.write(
' '
);
267
if
(bin3 >= 0.0)
Serial
.write(
' '
);
268
Serial
.print(bin3, 2);
269
Serial
.print(
" "
);
270
Serial
.print(amp1, 2);
271
Serial
.write(
' '
);
272
Serial
.print(amp2, 2);
273
Serial
.write(
' '
);
274
if
(phase1 >= 0.0)
Serial
.write(
' '
);
275
Serial
.print(phase1, 2);
276
Serial
.write(
' '
);
277
if
(phase2 >= 0.0)
Serial
.write(
' '
);
278
Serial
.print(phase2, 2);
279
Serial
.print(
" "
);
280
281
// Print the final amplitude and phase, which we use to decide what (if anything) we have found)
282
if
(ampAverage >= 0.0)
Serial
.write(
' '
);
283
Serial
.print(ampAverage, 1);
284
Serial
.write(
' '
);
285
286
lcd.setCursor(0,0);
287
lcd.print(
" "
);
288
lcd.print(ampAverage);
289
lcd.setCursor(0,1);
290
lbg.drawValue(ampAverage, max_ampAverage);
291
292
if
(phaseAverage >= 0.0)
Serial
.write(
' '
);
293
Serial
.print((
int
)phaseAverage);
294
295
// Decide what we have found and tell the user
296
if
(ampAverage >= threshold)
297
{
298
// When held in line with the centre of the coil:
299
// - non-ferrous metals give a negative phase shift, e.g. -90deg for thick copper or aluminium, a copper olive, -30deg for thin alumimium.
300
// Ferrous metals give zero phase shift or a small positive phase shift.
301
// So we'll say that anything with a phase shift below -20deg is non-ferrous.
302
if
(phaseAverage < -20.0)
303
{
304
Serial
.print(
" Non-ferrous"
);
305
lcd.setCursor(0,0);
306
lcd.print(
"NonFerous "
);
307
308
}
309
else
310
{
311
Serial
.print(
" Ferrous"
);
312
lcd.setCursor(0,0);
313
lcd.print(
"Ferrous "
);
314
}
315
float
temp = ampAverage;
316
317
int
thisPitch = map (temp, 10, 200, 100, 1500);
318
tone(3, thisPitch,120);
319
320
while
(temp > threshold)
321
{
322
Serial
.write(
'!'
);
323
temp -= (threshold/2);
324
}
325
}
326
Serial
.println();
327
328
}
329
while
(ticks - oldTicks < 8000)
330
{
331
}
332
}
Я правил так но у меня вылетает ошибка при компеляции.
Знаешь сколько ошибок компиляции бывает? Нет? Так выкладывай текстом - что за ошибка!
Мошт #ifndef твой "наоборот" ? ))
НЕА, так задумано, если библиотекаф i2c НЕТУ КОМПИЛИРОВАТЬСЯ ПОД ОБЫЧНЫЕ
01
//#define LCDI2C
02
03
#ifndef LCDI2C
04
#include <LiquidCrystal.h>
05
#include <LcdBarGraph.h>
06
LiquidCrystal lcd(6, 7, 10, 11, 12, 13);
07
LcdBarGraph lbg(&lcd, 16, 0, 1);
// <a href="https://github.com/prampec/LcdBarGraph" title="https://github.com/prampec/LcdBarGraph" rel="nofollow">https://github.com/prampec/LcdBarGraph</a>
08
#else
09
#include <LiquidCrystal_I2C.h> // <a href="https://github.com/troublegum/liquidcrystal_i2c" title="https://github.com/troublegum/liquidcrystal_i2c" rel="nofollow">https://github.com/troublegum/liquidcrystal_i2c</a>
10
#include <LcdBarGraph_I2C.h>
11
LiquidCrystal_I2C lcd(0x27,16,2);
12
LcdBarGraph_I2C lbg(&lcd, 16, 0, 1);
13
#endif
1
Скетч использует 10702 байт (33%) памяти устройства. Всего доступно 32256 байт.
2
Глобальные переменные используют 526 байт (25%) динамической памяти, оставляя 1522 байт для локальных переменных. Максимум: 2048 байт.
Не логично. Если ты объявляешь LCDI2C, то и подключай I2C-бибилиотеки. Так же по логике должно быть?...
а если не объявляешь )))
(ifndef)
Я правил так но у меня вылетает ошибка при компеляции.
Знаешь сколько ошибок компиляции бывает? Нет? Так выкладывай текстом - что за ошибка!
на правильных библиотеках нет там никаких ошибок
01
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
02
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
03
Using board
'uno'
from platform
in
folder: D:\ARDUINO\arduino-1.8.19\hardware\arduino\avr
04
Using core
'arduino'
from platform
in
folder: D:\ARDUINO\arduino-1.8.19\hardware\arduino\avr
05
Detecting libraries used...
06
"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
07
Alternatives
for
LiquidCrystal_I2C.h: [liquidcrystal_i2c-master@1.0]
08
ResolveLibrary(LiquidCrystal_I2C.h)
09
-> candidates: [liquidcrystal_i2c-master@1.0]
10
"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
11
Alternatives
for
Wire.h: [Wire@1.0]
12
ResolveLibrary(Wire.h)
13
-> candidates: [Wire@1.0]
14
"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
15
Alternatives
for
LcdBarGraph_I2C.h: [LcdBarGraph-master@2.0.1]
16
ResolveLibrary(LcdBarGraph_I2C.h)
17
-> candidates: [LcdBarGraph-master@2.0.1]
18
"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
19
"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
20
"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
21
"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
22
"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
23
Alternatives
for
LiquidCrystal.h: [LiquidCrystal@1.0.7]
24
ResolveLibrary(LiquidCrystal.h)
25
-> candidates: [LiquidCrystal@1.0.7]
26
"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
27
"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
28
"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
29
Generating function prototypes...
30
"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"
31
"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"
32
Компиляция скетча...
33
"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"
34
Compiling libraries...
35
Compiling library
"liquidcrystal_i2c-master"
36
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\liquidcrystal_i2c-master\LiquidCrystal_I2C.cpp.o
37
Compiling library
"Wire"
38
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\Wire\Wire.cpp.o
39
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\Wire\utility\twi.c.o
40
Compiling library
"LcdBarGraph-master"
41
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\LcdBarGraph-master\LcdBarGraph_I2C.cpp.o
42
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\LcdBarGraph-master\LcdBarGraph.cpp.o
43
Compiling library
"LiquidCrystal"
44
Используем предварительно скомпилированный файл: C:\Users\UA6EM\AppData\Local\Temp\arduino_build_464167\libraries\LiquidCrystal\LiquidCrystal.cpp.o
45
Compiling core...
46
Using precompiled core: C:\Users\UA6EM\AppData\Local\Temp\arduino_cache_366554\core\core_arduino_avr_uno_c47401c6bd8a389e878416c8e2c15e4a.a
47
Linking everything together...
48
"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
49
"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"
50
"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"
51
Используем библиотеку liquidcrystal_i2c-master версии 1.0 из папки: D:\ARDUINO\arduino-1.8.19\portable\sketchbook\libraries\liquidcrystal_i2c-master
52
Используем библиотеку Wire версии 1.0 из папки: D:\ARDUINO\arduino-1.8.19\hardware\arduino\avr\libraries\Wire
53
Используем библиотеку LcdBarGraph-master версии 2.0.1 из папки: D:\ARDUINO\arduino-1.8.19\portable\sketchbook\libraries\LcdBarGraph-master
54
Используем библиотеку LiquidCrystal версии 1.0.7 из папки: D:\ARDUINO\arduino-1.8.19\libraries\LiquidCrystal
55
"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"
56
Скетч использует 11164 байт (34%) памяти устройства. Всего доступно 32256 байт.
57
Глобальные переменные используют 588 байт (28%) динамической памяти, оставляя 1460 байт для локальных переменных. Максимум: 2048 байт.
Согласен, я готовлю:) но не в ардуино, яж говорю только верхушек нахватался.
Согласен долго я искал библиотеку что бы хоть холо ворл заработал.
Вод подробная ошибка.
001
Arduino: 1.8.19 (Windows 10), Плата:
"Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
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
024
025
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
026
027
Using board
'pro'
from platform
in
folder: D:\Arduino\hardware\arduino\avr
028
029
Using core
'arduino'
from platform
in
folder: D:\Arduino\hardware\arduino\avr
030
031
Detecting libraries used...
032
033
"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
034
035
Alternatives
for
Wire.h: [Wire@1.0]
036
037
ResolveLibrary(Wire.h)
038
039
-> candidates: [Wire@1.0]
040
041
"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
042
043
Alternatives
for
LiquidCrystal_I2C.h: [Arduino-LiquidCrystal-I2C-library-master]
044
045
ResolveLibrary(LiquidCrystal_I2C.h)
046
047
-> candidates: [Arduino-LiquidCrystal-I2C-library-master]
048
049
"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
050
051
Alternatives
for
EEPROM.h: [EEPROM@2.0]
052
053
ResolveLibrary(EEPROM.h)
054
055
-> candidates: [EEPROM@2.0]
056
057
"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
058
059
"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
060
061
"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
062
063
"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
064
065
Generating function prototypes...
066
067
"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"
068
069
"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"
070
071
Компиляция скетча...
072
073
"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"
074
075
D:\arduino_code\arduino_code.ino: In function
'void setup()'
:
076
077
arduino_code:85:18: error: no matching function
for
call to
'LiquidCrystal_I2C::begin(int, int)'
078
079
lcd.begin(16, 2);
// LCD 16X2
080
081
^
082
083
In file included from D:\arduino_code\arduino_code.ino:27:0:
084
085
D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate:
void
LiquidCrystal_I2C::begin()
086
087
void
begin();
088
089
^~~~~
090
091
D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: candidate expects 0 arguments, 2 provided
092
093
D:\arduino_code\arduino_code.ino: In function
'void loop()'
:
094
095
arduino_code:290:9: error:
'lbg'
was not declared
in
this
scope
096
097
lbg.drawValue(ampAverage, max_ampAverage);
098
099
^~~
100
101
D:\arduino_code\arduino_code.ino:290:9: note: suggested alternative:
'log'
102
103
lbg.drawValue(ampAverage, max_ampAverage);
104
105
^~~
106
107
log
108
109
arduino_code:290:35: error:
'max_ampAverage'
was not declared
in
this
scope
110
111
lbg.drawValue(ampAverage, max_ampAverage);
112
113
^~~~~~~~~~~~~~
114
115
D:\arduino_code\arduino_code.ino:290:35: note: suggested alternative:
'ampAverage'
116
117
lbg.drawValue(ampAverage, max_ampAverage);
118
119
^~~~~~~~~~~~~~
120
121
ampAverage
122
123
Используем библиотеку Wire версии 1.0 из папки: D:\Arduino\hardware\arduino\avr\libraries\Wire
124
125
Используем библиотеку Arduino-LiquidCrystal-I2C-library-master в папке: D:\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master (legacy)
126
127
Используем библиотеку EEPROM версии 2.0 из папки: D:\Arduino\hardware\arduino\avr\libraries\EEPROM
128
129
exit status 1
130
131
no matching function
for
call to
'LiquidCrystal_I2C::begin(int, int)'
библиотеку LcdBarGraph.h тоже надо под I2C переписать
Как? наверное потому я и здесь со своей просьбой.
Как? наверное потому я и здесь со своей просьбой.
обычно если сам не можешь заказываешь компетентный сервис )))
Так научите это ... как сложно. Да и зачем нужна lcdbargraph.h если я собираюсь под i2c переписать код. С меня в контакте ардуинщик-бизнесмен запросил 1000 рублей это не вы случайно?
это не я и, ...так как ты просишь чтобы один неуч учил второго неуча в этом случае ставка будет сильно выше, 4 часа 7 тыр )))
PS это не договор оферты...размышления вслух...
Ясно зря зашёл, ну всё равно спасибо, здоровья вам и удачи.
Ты богатый и очереди у тебя? Удачи в бизнесе.
Ты богатый и очереди у тебя? Удачи в бизнесе.
А ты бедный и безмозглый.
Готовое купи, это дешевле.
Ясно зря зашёл, ну всё равно спасибо, здоровья вам и удачи.
почему же зря, скетч тебе дали поправленный (заметь - безвозмездно), осталось решить или новый дисплей купить, или у этого выпаять контроллер или штуку заплатить тому, кто тебе предлагал ...это если по быстрому...
PS обычно хорошим тоном считается приводить ссылку на автора проекта
Не забываем, что не все библиотеки LCD_I2C поддерживают необходимые нам функции, официальная - нет.
01
// unsupported API functions
02
void
LiquidCrystal_I2C::off(){}
03
void
LiquidCrystal_I2C::on(){}
04
void
LiquidCrystal_I2C::setDelay (
int
cmdDelay,
int
charDelay) {}
05
uint8_t LiquidCrystal_I2C::status(){
return
0;}
06
uint8_t LiquidCrystal_I2C::keypad (){
return
0;}
07
uint8_t LiquidCrystal_I2C::init_bargraph(uint8_t graphtype){
return
0;}
08
void
LiquidCrystal_I2C::draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end){}
09
void
LiquidCrystal_I2C::draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_row_end){}
10
void
LiquidCrystal_I2C::setContrast(uint8_t new_val){}
Проще гребенку снять ))))
Проще гребенку снять ))))
проще новый дисплей купить )))