-
Взял уже готовый код, но он не хочет работать. Жалуется на строки: DallasTemperature sensors(&oneWire);
Сообщение об ошибке:
Arduino: 1.6.7 (Windows 10), Плата:»Arduino/Genuino Uno»C:UsersUserDocuments1sketchsketch.ino: In function ‘void loop()’:
sketch:74: error: ‘led1’ was not declared in this scope
digitalWrite (led1, HIGH);
^
sketch:78: error: ‘led1’ was not declared in this scope
digitalWrite(led1, LOW);
^
C:UsersUserDocuments1sketchsketch.ino: At global scope:
sketch:88: error: redefinition of ‘OneWire oneWire’
OneWire oneWire(ONE_WIRE_BUS);
^
sketch:7: error: ‘OneWire oneWire’ previously declared here
OneWire oneWire(ONE_WIRE_BUS);
^
sketch:89: error: redefinition of ‘DallasTemperature sensors’
DallasTemperature sensors(&oneWire);
^
sketch:8: error: ‘DallasTemperature sensors’ previously declared here
DallasTemperature sensors(&oneWire);
^
sketch:91: error: redefinition of ‘byte mac []’
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
^
sketch:10: error: ‘byte mac [6]’ previously defined here
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
^
sketch:93: error: redefinition of ‘EthernetClient client’
EthernetClient client;
^
sketch:12: error: ‘EthernetClient client’ previously declared here
EthernetClient client;
^
sketch:94: error: redefinition of ‘char server []’
char server[] = «*************»; // РёРјСЏ вашего сервера
^
sketch:13: error: ‘char server [14]’ previously defined here
char server[] = «*************»; // РёРјСЏ вашего сервера www.arduino.ru
^
sketch:95: error: redefinition of ‘int buff’
int buff=0;
^
sketch:14: error: ‘int buff’ previously defined here
int buff=0;
^
sketch:96: error: redefinition of ‘const int led’
const int led=5;
^
sketch:15: error: ‘const int led’ previously defined here
const int led=5;
^
C:UsersUserDocuments1sketchsketch.ino: In function ‘void setup()’:
sketch:98: error: redefinition of ‘void setup()’
void setup()
^
sketch:17: error: ‘void setup()’ previously defined here
void setup()
^
C:UsersUserDocuments1sketchsketch.ino: In function ‘void loop()’:
sketch:106: error: redefinition of ‘void loop()’
void loop()
^
sketch:25: error: ‘void loop()’ previously defined here
void loop()
^
sketch:155: error: ‘led1’ was not declared in this scope
digitalWrite (led1, HIGH);
^
sketch:159: error: ‘led1’ was not declared in this scope
digitalWrite(led1, LOW);
^
exit status 1
‘led1’ was not declared in this scopeКод программы:
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
EthernetClient client;
char server[] = «*************»; // имя вашего сервера www.arduino.ru
int buff=0;
const int led=5;void setup()
{
Ethernet.begin(mac);
sensors.begin();
pinMode( led, OUTPUT);
digitalWrite(led, LOW);
}void loop()
{
sensors.requestTemperatures();
if (client.connect(server, 80))
{client.print( «GET /add_data.php?»);
client.print(«temperature=»);
client.print( sensors.getTempCByIndex(0) );
client.print(«&»);
client.print(«&»);
client.print(«temperature1=»);
client.print( sensors.getTempCByIndex(1) );
client.println( » HTTP/1.1″);
client.print( «Host: » );
client.println(server);
client.println( «Connection: close» );
client.println();
client.println();delay(200);
while (client.available())
{
char c = client.read();
if ( c==’1′)
{
buff=1;
}
if ( c==’0′)
{
buff=0;
}
}
client.stop();
client.flush();
delay(100);
}
else
{
client.stop();
delay(1000);
client.connect(server, 80);
}if ( buff==1)
{
digitalWrite (led1, HIGH);
}
else
{
digitalWrite(led1, LOW);
}
delay(500);
}
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
EthernetClient client;
char server[] = «*************»; // имя вашего сервера
int buff=0;
const int led=5;void setup()
{
Ethernet.begin(mac);
sensors.begin();
pinMode( led, OUTPUT);
digitalWrite(led, LOW);
}void loop()
{
sensors.requestTemperatures();
if (client.connect(server, 80))
{client.print( «GET /add_data.php?»);
client.print(«temperature=»);
client.print( sensors.getTempCByIndex(0) );
client.print(«&»);
client.print(«&»);
client.print(«temperature1=»);
client.print( sensors.getTempCByIndex(1) );
client.println( » HTTP/1.1″);
client.print( «Host: » );
client.println(server);
client.println( «Connection: close» );
client.println();
client.println();delay(200);
while (client.available())
{
char c = client.read();
if ( c==’1′)
{
buff=1;
}
if ( c==’0′)
{
buff=0;
}
}
client.stop();
client.flush();
delay(100);
}
else
{
client.stop();
delay(1000);
client.connect(server, 80);
}if ( buff==1)
{
digitalWrite (led1, HIGH);
}
else
{
digitalWrite(led1, LOW);
}
delay(500);
} -
Так приятнее смотреть. Глаза не напрягаются:
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
EthernetClient client;
char server[] = «*************»; // имя вашего сервера www.arduino.ru
int buff=0;
const int led=5;void setup()
{
Ethernet.begin(mac);
sensors.begin();
pinMode( led, OUTPUT);
digitalWrite(led, LOW);
}void loop()
{
sensors.requestTemperatures();
if (client.connect(server, 80))
{client.print( «GET /add_data.php?»);
client.print(«temperature=»);
client.print( sensors.getTempCByIndex(0) );
client.print(«&»);
client.print(«&»);
client.print(«temperature1=»);
client.print( sensors.getTempCByIndex(1) );
client.println( » HTTP/1.1″);
client.print( «Host: « );
client.println(server);
client.println( «Connection: close» );
client.println();
client.println();delay(200);
while (client.available())
{
char c = client.read();
if ( c==‘1’)
{
buff=1;
}
if ( c==‘0’)
{
buff=0;
}
}
client.stop();
client.flush();
delay(100);
}
else
{
client.stop();
delay(1000);
client.connect(server, 80);
}if ( buff==1)
{
digitalWrite (led1, HIGH);
}
else
{
digitalWrite(led1, LOW);
}
delay(500);
}
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
EthernetClient client;
char server[] = «*************»; // имя вашего сервера
int buff=0;
const int led=5;void setup()
{
Ethernet.begin(mac);
sensors.begin();
pinMode( led, OUTPUT);
digitalWrite(led, LOW);
}void loop()
{
sensors.requestTemperatures();
if (client.connect(server, 80))
{client.print( «GET /add_data.php?»);
client.print(«temperature=»);
client.print( sensors.getTempCByIndex(0) );
client.print(«&»);
client.print(«&»);
client.print(«temperature1=»);
client.print( sensors.getTempCByIndex(1) );
client.println( » HTTP/1.1″);
client.print( «Host: « );
client.println(server);
client.println( «Connection: close» );
client.println();
client.println();delay(200);
while (client.available())
{
char c = client.read();
if ( c==‘1’)
{
buff=1;
}
if ( c==‘0’)
{
buff=0;
}
}
client.stop();
client.flush();
delay(100);
}
else
{
client.stop();
delay(1000);
client.connect(server, 80);
}if ( buff==1)
{
digitalWrite (led1, HIGH);
}
else
{
digitalWrite(led1, LOW);
}
delay(500);
} -
Объявите все переменные, которые вы использовали. Пока у меня нет времени… Может кто другой найдется. Вот статья: http://arduino.ru/Tutorial/Variables
-
Первая ошибка 74 строка кода led1 от куда? Было led Копируете текст ошибок и в переводчик более понятно становиться
SergeyKagen 3 / 4 / 2 Регистрация: 02.04.2018 Сообщений: 315 |
||||
1 |
||||
19.04.2019, 22:16. Показов 131712. Ответов 14 Метки нет (Все метки)
Простой код, но Arduino IDE напрочь отказывается принимать переменные. Что за глюк или я что-то неправильно делаю?
ошибка при компиляции «‘count’ was not declared in this scope», что не так?
__________________
0 |
marat_miaki 495 / 389 / 186 Регистрация: 08.04.2013 Сообщений: 1,688 |
||||
19.04.2019, 23:26 |
2 |
|||
Решение
1 |
Lavad 0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
||||||||
14.09.2019, 22:33 |
3 |
|||||||
Доброго времени суток!
В loop() делаю вызов:
При компиляции выделяется этот вызов, с сообщением: ‘myDisplay’ was not declared in this scope Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции P.S. Код, что использовал в качестве функции, работоспособен. Раньше находился в loop(). Скетч постепенно разрастается, много однотипных обращений к дисплею…
0 |
8385 / 6147 / 615 Регистрация: 10.12.2010 Сообщений: 28,683 Записей в блоге: 30 |
|
14.09.2019, 23:57 |
4 |
Создал функцию (за пределами setup и loop), Перевидите на нормальный язык. В другом файле что ли? Добавлено через 1 минуту
Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции Читать учебники по С++ не пробовали? https://metanit.com/cpp/tutorial/3.1.php Специфика Arduino лишь отличается тем что пред объявления не всегда нужны. Добавлено через 7 минут
0 |
ValeryS Модератор 8759 / 6549 / 887 Регистрация: 14.02.2011 Сообщений: 22,972 |
||||
15.09.2019, 00:09 |
5 |
|||
Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции это где ж такое написано?
а объявить уже в удобном месте
0 |
0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
|
15.09.2019, 00:48 |
6 |
Неделю назад ВПЕРВЫЕ включил Arduino Uno. Написал на том же языке, что и читал на всяких форумах и справочниках по Arduino :-). За пределами этих функций — значит не внутри них. Обе приведенных Вами ссылок просмотрел, проверил в скетче… В итоге вылезла другая ошибка: void myDisplay(byte x, byte y, char str) тоже пробовал. Та же ошибка. Что не так на этот раз?
0 |
Модератор 8759 / 6549 / 887 Регистрация: 14.02.2011 Сообщений: 22,972 |
|
15.09.2019, 01:26 |
7 |
В итоге вылезла другая ошибка: точку с запятой в конце поставил?
1 |
Lavad 0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
||||||||||||
15.09.2019, 08:46 |
8 |
|||||||||||
Вот скетч. Проще некуда.
Любое из трех так называемых «объявлений» (строки 7…9) выдает одну и ту же ошибку — я пытаюсь объявить функцию как переменную. Добавлено через 9 минут
Компилятор задумался (я успел обрадоваться), но, зараза :-), он снова поставил свой автограф undefined reference to `myDisplay(unsigned char, unsigned char, char, float) На этот раз он пожаловался на строку вызова функции. Добавлено через 34 минуты
Dispay вместо Display Добавлено через 8 минут
0 |
ValeryS Модератор 8759 / 6549 / 887 Регистрация: 14.02.2011 Сообщений: 22,972 |
||||||||
15.09.2019, 10:36 |
9 |
|||||||
void myDisplay(byte, byte, char, float) = 0; вот так не надо делать(приравнивать функцию к нулю) Добавлено через 5 минут
void myDispay(byte x, byte y, char str, float temp)
myDisplay(0, 0, «C», temp); просишь чтобы функция принимала символ
или проси передавать строку, например так
1 |
Avazart 8385 / 6147 / 615 Регистрация: 10.12.2010 Сообщений: 28,683 Записей в блоге: 30 |
||||
15.09.2019, 12:02 |
10 |
|||
Кроме того наверное лучше так:
Тогда можно будет вынести ф-цию в отдельный файл/модуль.
1 |
locm |
15.09.2019, 21:07
|
Не по теме:
Arduino Uno.
AVR (Basic, немного Assembler). Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере.
0 |
Avazart |
15.09.2019, 21:21
|
Не по теме:
Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере. Но лучше не надо …
0 |
Lavad 0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
||||
16.09.2019, 12:12 |
13 |
|||
это где ж такое написано? Оказалось, что я верно понял чтиво по справочникам:
вот так не надо делать(приравнивать функцию к нулю)… Методом проб и ошибок уже понял :-).
или передавай символ… Если передаю в одинарных кавычках более одного символа, а функция ждет как
или проси передавать строку, например так… Буквально вчера попалось это в справочнике, но как-то не дошло, что тоже мой вариант :-).
Кроме того наверное лучше так:
Тогда можно будет вынести ф-цию в отдельный файл/модуль. Благодарю за совет! Как-нибудь проверю…
0 |
8385 / 6147 / 615 Регистрация: 10.12.2010 Сообщений: 28,683 Записей в блоге: 30 |
|
16.09.2019, 12:54 |
14 |
Оказалось, что я верно понял чтиво по справочникам: если ты вызываешь функцию, это и есть обьявление функции Нафиг выкиньте эти справочники.
0 |
0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
|
16.09.2019, 13:00 |
15 |
Ссылки Ваши добавлены в закладки. Время от времени заглядываю.
0 |
I got a problem with this code from Arduino Projects Book, a very simple code soryy if is very obvius.
This is the code I wrote:
const int greenLEDpin = 9;
const int redLEDpin = 10;
const int blueLEDpin = 11;
const int redSensorpin = A0;
const int greenSensorpin = A1;
const int blueSensorpin = A2;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
void setup() {
Serial.begin(9600);
pinMode(greenLEDpin,OUTPUT);
pinMode(redLEDpin,OUTPUT);
pinMode(blueLEDpin,OUTPUT);
}
void loop() {
redSensorValue = analogRead(redSensorpin);
delay (5);
greenSensorValue = analogRead(greenSensorpin);
delay(5);
blueSensorValue = analogRead(blueSensorpin);
Serial.print("Raw Sensor Values t Red: ");
Serial.print(redSensorValue);
Serial.print("t Green: ");
Serial.print(greenSensorValue);
Serial.print("t Blue: ");
Serial.println(blueSensorValue);
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;
Serial.print("Mapped Sensor Values t ReD: ");
Serial.print(redValue);
Serial.print("t Green: ");
Serial.print(greenValue);
Serial.print("t Blue: ");
Serial.print(blueValue);
analogWrite(redLEDpin, redValue);
analogWrite(greenLEDpin, greenValue);
analogWrite(blueLEDpin, blueValue);
}
And here is the error:
Arduino:1.7.10 (Windows 8.1), Placa:»Arduino Uno»
LED_tricolor.ino: In function 'void loop()':
LED_tricolor.ino:24:2: error: 'redSensorValue' was not declared in this scope
LED_tricolor.ino:26:2: error: 'greenSensorValue' was not declared in this scope
LED_tricolor.ino:28:2: error: 'blueSensorValue' was not declared in this scope
Someone knows whats happening here? I tried some things like puting the variables before, but nothing…
Hope u guys can help me ^^.
СОДЕРЖАНИЕ ►
- Произошла ошибка при загрузке скетча в Ардуино
- programmer is not responding
- a function-definition is not allowed arduino ошибка
- expected initializer before ‘}’ token arduino ошибка
- ‘что-то’ was not declared in this scope arduino ошибка
- No such file or directory arduino ошибка
- Compilation error: Missing FQBN (Fully Qualified Board Name)
Ошибки компиляции Arduino IDE возникают при проверке или загрузке скетча в плату, если код программы содержит ошибки, компилятор не может найти библиотеки или переменные. На самом деле, сообщение об ошибке при загрузке скетча связано с невнимательностью самого программиста. Рассмотрим в этой статье все возможные ошибки компиляции для платы Ардуино UNO R3, NANO, MEGA и пути их решения.
Произошла ошибка при загрузке скетча Ардуино
Самые простые ошибки возникают у новичков, кто только начинает разбираться с языком программирования Ардуино и делает первые попытки загрузить скетч. Если вы не нашли решение своей проблемы в статье, то напишите свой вопрос в комментариях к этой записи и мы поможем решить вашу проблему с загрузкой (бесплатно!).
avrdude: stk500_recv(): programmer is not responding
Что делать в этом случае? Первым делом обратите внимание какую плату вы используете и к какому порту она подключена (смотри на скриншоте в правом нижнем углу). Необходимо сообщить Arduino IDE, какая плата используется и к какому порту она подключена. Если вы загружаете скетч в Ардуино Nano V3, но при этом в настройках указана плата Uno или Mega 2560, то вы увидите ошибку, как на скриншоте ниже.
Такая же ошибка будет возникать, если вы не укажите порт к которому подключена плата (это может быть любой COM-порт, кроме COM1). В обоих случаях вы получите сообщение — плата не отвечает (programmer is not responding). Для исправления ошибки надо на панели инструментов Arduino IDE в меню «Сервис» выбрать нужную плату и там же, через «Сервис» → «Последовательный порт» выбрать порт «COM7».
a function-definition is not allowed here before ‘{‘ token
Это значит, что в скетче вы забыли где-то закрыть фигурную скобку. Синтаксические ошибки IDE тоже распространены и связаны они просто с невнимательностью. Такие проблемы легко решаются, так как Arduino IDE даст вам подсказку, стараясь отметить номер строки, где обнаружена ошибка. На скриншоте видно, что строка с ошибкой подсвечена, а в нижнем левом углу приложения указан номер строки.
expected initializer before ‘}’ token / expected ‘;’ before ‘}’ token
Сообщение expected initializer before ‘}’ token говорит о том, что вы, наоборот где-то забыли открыть фигурную скобку. Arduino IDE даст вам подсказку, но если скетч довольно большой, то вам придется набраться терпения, чтобы найти неточность в коде. Ошибка при компиляции программы: expected ‘;’ before ‘}’ token говорит о том, что вы забыли поставить точку с запятой в конце командной строки.
‘что-то’ was not declared in this scope
Что за ошибка? Arduino IDE обнаружила в скетче слова, не являющиеся служебными или не были объявлены, как переменные. Например, вы забыли продекларировать переменную или задали переменную ‘DATA’, а затем по невнимательности используете ‘DAT’, которая не была продекларирована. Ошибка was not declared in this scope возникает при появлении в скетче случайных или лишних символов.
Например, на скриншоте выделено, что программист забыл продекларировать переменную ‘x’, а также неправильно написал функцию ‘analogRead’. Такая ошибка может возникнуть, если вы забудете поставить комментарий, написали функцию с ошибкой и т.д. Все ошибки также будут подсвечены, а при нескольких ошибках в скетче, сначала будет предложено исправить первую ошибку, расположенную выше.
exit status 1 ошибка компиляции для платы Arduino
Данная ошибка возникает, если вы подключаете в скетче библиотеку, которую не установили в папку libraries. Например, не установлена библиотека ИК приемника Ардуино: fatal error: IRremote.h: No such file or directory. Как исправить ошибку? Скачайте нужную библиотеку и распакуйте архив в папку C:Program FilesArduinolibraries. Если библиотека установлена, то попробуйте скачать и заменить библиотеку на новую.
Довольно часто у новичков выходит exit status 1 ошибка компиляции для платы arduino uno /genuino uno. Причин данного сообщения при загрузке скетча в плату Arduino Mega или Uno может быть огромное множество. Но все их легко исправить, достаточно внимательно перепроверить код программы. Если в этом обзоре вы не нашли решение своей проблемы, то напишите свой вопрос в комментариях к этой статье.
missing fqbn (fully qualified board name)
Ошибка возникает, если не была выбрана плата. Обратите внимание, что тип платы необходимо выбрать, даже если вы не загружаете, а, например, делаете компиляцию скетча. В Arduino IDE 2 вы можете использовать меню выбора:
— список плат, которые подключены и были идентифицированы Arduino IDE.
— или выбрать плату и порт вручную, без подключения микроконтроллера.
Arduino programming is an open-source and simple stage that arranges the Arduino board into working with a particular goal in mind. An Arduino code is written in C++ yet with extra capacities and strategies. An Arduino is an equipment and programming stage broadly utilised in hardware.
In this article, we go through three quick fixes for the error ‘was not declared in this scope’.
Also read: How to solve the Tower of Hanoi problem using Python?
What does the error mean?
Every programming language has a concept of Scope. Scope tells us where a specific variable, constant or function is accessible and usable. It refers to the area of code a statement, block, or name. The scope of an entity determines where that entity is usable in other parts of the program. The scope of a block determines where that block can be used in other blocks, and the scope of a name determines where that name can be used in other names.
There are two types of scope in programming languages: local and global. Local scope refers to the identifiers and symbols visible inside a block of code. Global scope, on the other hand, refers to the identifiers and symbols visible outside a block of code.
The error ‘was not declared in this scope’ generally occurs when a variable or function is not accessible to its call. A global variable in Arduino is the variable that is declared outside any function, including the setup() and loop() functions. Any variable declared inside a function or loop has restrictive access and is a local variable.
If any other function calls a local variable, it gives an error. To call any variable or function in any other function, including the setup() and loop() function, it should be declared as a global variable.
Also read: How to stop an Arduino program?
There are the quick fixes for the Arduino error: was not declared in the scope.
Declare the variable
Before assigning a value to the variable, make sure to define it. There are 16 data types commonly used in Arduino coding. Each data type expresses the nature of the value assigned to it. If the data type and value doesn’t match, an error arises. Also, if a variable is assigned any value without its declaration or data type, the error occurs.
Always ensure to declare the variable before the assignment. There are two ways to do this.
There are three variables in the above example – num1, num2 and num3. The variable num1 has been declared separately and assigned to a data type corresponding value in the loop. The variable num2 has been declared and assigned in the same line of code. The variable num3, on the other hand, has directly been assigned a value without its declaration. This causes the error, as shown above.
Other details
There may be errors arising even after proper declaration and assignment of the variable. This may be due to incorrect or absence of the closing brackets, semicolons or improper declaration of functions. Ensure proper use of syntax when defining loops and functions. Every opening in curly brace must be accounted for and closed. Extra closing braces also cause errors. Alongside, semicolons hold their importance. A semicolon missed can cause the entire program to go haywire.
Library folder
Many times, variables call or use functions that require importing a few specific libraries.
In the example above, the variable num calls the square root function – sqrt() from the maths library of Arduino. If we call a function without including its library first, an error occurs. There are multiple inbuilt and standard libraries in Arduino, while a few special libraries must be included separately.
Also read: What is ‘does not name a type’ in Arduino: 2 Fixes.
Here is the code :
#include <LiquidCrystal.h> const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); float currentTemp = tempsensor(); int ledPin = 13; int inPin = 7; int val = 0; digitalWrite(LED, HIGH); digitalWrite(LED, LOW); void setup() { pinMode(ledPin, OUTPUT); pinMode(inPin, INPUT); lcd.begin(16, 2); } void loop() { val = digitalRead(inPin); if (val == HIGH) { float currentTemp = tempsensor(); if(currentTemp<maxTemp){ digitalWrite(LED, HIGH); }else if(currentTemp>maxTemp){ digitalWrite(LED, LOW); }else{} lcd.setCursor(0, 1); lcd.print(maxTemp); } }
Here are the errors:
ArduinoLcdButtonFunctions:71: error: 'tempsensor' was not declared in this scope float currentTemp = tempsensor(); ^ ArduinoLcdButtonFunctions:72: error: 'maxTemp' was not declared in this scope if(currentTemp<maxTemp){ ^ ArduinoLcdButtonFunctions:74: error: 'LED' was not declared in this scope digitalWrite(LED, HIGH); ^ ArduinoLcdButtonFunctions:77: error: 'LED' was not declared in this scope digitalWrite(LED, LOW); ^ ArduinoLcdButtonFunctions:83: error: 'maxTemp' was not declared in this scope lcd.print(maxTemp); ^ exit status 1 'tempsensor' was not declared in this scope
What can I do to fix this ???
What I have tried:
Ardiuno Forums, Youtube, StackOverFlow forums.