не компилируется код
- Войдите на сайт для отправки комментариев
Пнд, 10/07/2017 - 11:27
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <DHT11.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
float temperature[2];
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
lcd.begin(16, 2);
lcd.backlight();
lcd.clear();
lcd.print("Humidity & temp");
delay(1000);
lcd.clear();
lcd.print("Starting.....");
delay(1000);
}
void loop(void)
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read(temperature, sizeof(temperature));
lcd.clear();
delay(500);
lcd.setCursor(0, 0);
lcd.print("Temp");
lcd.setCursor(0, 1);
lcd.print("Humidity");
lcd.setCursor(9, 0);
lcd.print(temperature[0]);
lcd.print(" C");
lcd.setCursor(9, 1);
lcd.print(temperature[1]);
lcd.print(" %");
delay(1000);
}
}
else
{
lcd.setCursor(0, 0);
lcd.print("No radio available");
}
}
пишет ошибку
C:\Users\СЏ\Desktop\_____\_____.ino: In function 'void loop()':
_____:39: error: void value not ignored as it ought to be
Чтобы нашелся желающий помочь вам и отыскать строку 39, прочтите это
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #include <DHT11.h> #include <Wire.h> #include <LCD.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity float temperature[2]; RF24 radio(9, 10); const uint64_t pipe = 0xE8E8F0F0E1LL; void setup(void) { Serial.begin(9600); radio.begin(); radio.openReadingPipe(1, pipe); radio.startListening(); lcd.begin(16, 2); lcd.backlight(); lcd.clear(); lcd.print("Humidity & temp"); delay(1000); lcd.clear(); lcd.print("Starting....."); delay(1000); } void loop(void) { if ( radio.available() ) { bool done = false; while (!done) { done = radio.read(temperature, sizeof(temperature)); lcd.clear(); delay(500); lcd.setCursor(0, 0); lcd.print("Temp"); lcd.setCursor(0, 1); lcd.print("Humidity"); lcd.setCursor(9, 0); lcd.print(temperature[0]); lcd.print(" C"); lcd.setCursor(9, 1); lcd.print(temperature[1]); lcd.print(" %"); delay(1000); } } else { lcd.setCursor(0, 0); lcd.print("No radio available"); } }преобразуйте явно указатель на массив temperature к типу (void *) или (byte *)
честно,ничего в этом не понимаю,могу только по аналогии что то делать,но что только не пробовал ничего не получается.
если не трудно подскажите как жто делается.
Если в сообщении 3 номера строк соотвествуют диагностике компилятора из сообщения 1, то попробуйте
таже ошибка,ничего не изменилось
Какая версия IDE Arduino используется ?
Приведите компилируемый код без (сверните на дополнительной вкладке длинный текст кода) и диагностику компилятора.
в этой библиотеке метод "read()" возвращает void, то есть ничего не возвращает.
а ты присваиваешь это "ничего" переменной. О чем тебе компилятор и написал. Если не дошло - в дворники! У них ЗП повысили, говорят.
-----------------
сорри за опечатки - очень грязная клава на кухне. ;)
разжевываю:
Всем бобра! ;)
Всем бобра! ;)
а ты присваиваешь это "ничего" переменной. О чем тебе компилятор и написал. Если не дошло - в дворники! У них ЗП повысили, говорят.
метод имеет тип bool, а не void.
Даташит на библиотеку: bool RF24::read ( void * buf, uint8_t len)
Read the payload.
Код метода:
/****************************************************************************/ bool RF24::read( void* buf, uint8_t len ) { // Fetch the payload read_payload( buf, len ); // was this the last of the data available? return read_register(FIFO_STATUS) & _BV(RX_EMPTY); } /****************************************************************************/Судя по вопросам, в интернете гуляют версии библиотеки и с void и c bool. Автор может просто заглянуть в RF24.h и проверить сам какого типа функция read
с этой строкой ошибка ушла,теперь ошибка компиляции для любой платы,все перепробовал.
Вот тебе кусрк кода RF24.h. Ты, в другой раз, с папкой свом спор затевай, если есть.
class RF24 { private: #ifdef SOFTSPI SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi; #elif defined (SPI_UART) SPIUARTClass uspi; #endif #if defined (RF24_LINUX) || defined (XMEGA_D3) /* XMEGA can use SPI class */ SPI spi; #endif #if defined (MRAA) GPIO gpio; #endif uint8_t ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */ uint8_t csn_pin; /**< SPI Chip select */ uint16_t spi_speed; /**< SPI Bus Speed */ #if defined (RF24_LINUX) || defined (XMEGA_D3) uint8_t spi_rxbuff[32+1] ; //SPI receive buffer (payload max 32 bytes) uint8_t spi_txbuff[32+1] ; //SPI transmit buffer (payload max 32 bytes + 1 byte for the command) #endif bool p_variant; /* False for RF24L01 and true for RF24L01P */ uint8_t payload_size; /**< Fixed size of payloads */ bool dynamic_payloads_enabled; /**< Whether dynamic payloads are enabled. */ uint8_t pipe0_reading_address[5]; /**< Last address set on pipe 0 for reading. */ uint8_t addr_width; /**< The address width to use - 3,4 or 5 bytes. */ uint32_t txRxDelay; /**< Var for adjusting delays depending on datarate */ protected: /** * SPI transactions * * Common code for SPI transactions including CSN toggle * */ inline void beginTransaction(); inline void endTransaction(); public: /** * @name Primary public interface * * These are the main methods you need to operate the chip */ /**@{*/ /** * Arduino Constructor * * Creates a new instance of this driver. Before using, you create an instance * and send in the unique pins that this chip is connected to. * * @param _cepin The pin attached to Chip Enable on the RF module * @param _cspin The pin attached to Chip Select */ RF24(uint8_t _cepin, uint8_t _cspin); //#if defined (RF24_LINUX) /** * Optional Linux Constructor * * Creates a new instance of this driver. Before using, you create an instance * and send in the unique pins that this chip is connected to. * * @param _cepin The pin attached to Chip Enable on the RF module * @param _cspin The pin attached to Chip Select * @param spispeed For RPi, the SPI speed in MHZ ie: BCM2835_SPI_SPEED_8MHZ */ RF24(uint8_t _cepin, uint8_t _cspin, uint32_t spispeed ); //#endif #if defined (RF24_LINUX) virtual ~RF24() {}; #endif /** * Begin operation of the chip * * Call this in setup(), before calling any other methods. * @code radio.begin() @endcode */ bool begin(void); /** * Start listening on the pipes opened for reading. * * 1. Be sure to call openReadingPipe() first. * 2. Do not call write() while in this mode, without first calling stopListening(). * 3. Call available() to check for incoming traffic, and read() to get it. * * @code * Open reading pipe 1 using address CCCECCCECC * * byte address[] = { 0xCC,0xCE,0xCC,0xCE,0xCC }; * radio.openReadingPipe(1,address); * radio.startListening(); * @endcode */ void startListening(void); /** * Stop listening for incoming messages, and switch to transmit mode. * * Do this before calling write(). * @code * radio.stopListening(); * radio.write(&data,sizeof(data)); * @endcode */ void stopListening(void); /** * Check whether there are bytes available to be read * @code * if(radio.available()){ * radio.read(&data,sizeof(data)); * } * @endcode * @return True if there is a payload available, false if none is */ bool available(void); /** * Read the available payload * * The size of data read is the fixed payload size, see getPayloadSize() * * @note I specifically chose 'void*' as a data type to make it easier * for beginners to use. No casting needed. * * @note No longer boolean. Use available to determine if packets are * available. Interrupt flags are now cleared during reads instead of * when calling available(). * * @param buf Pointer to a buffer where the data should be written * @param len Maximum number of bytes to read into the buffer * * @code * if(radio.available()){ * radio.read(&data,sizeof(data)); * } * @endcode * @return No return value. Use available(). */ void read( void* buf, uint8_t len ); /** * Be sure to call openWritingPipe() first to set the destination * of where to write to. * * This blocks until the message is successfully acknowledged by * the receiver or the timeout/retransmit maxima are reached. In * the current configuration, the max delay here is 60-70ms. * * The maximum size of data written is the fixed payload size, see * getPayloadSize(). However, you can write less, and the remainder * will just be filled with zeroes. * * TX/RX/RT interrupt flags will be cleared every time write is called * * @param buf Pointer to the data to be sent * @param len Number of bytes to be sent * * @code * radio.stopListening(); * radio.write(&data,sizeof(data)); * @endcode * @return True if the payload was delivered successfully false if not */ bool write( const void* buf, uint8_t len );Если версия c void , то я не завидую ее пользователю. Многократно проверено - read не всегда удается чтение с первого раза и нужен контроль за исполнением функции. Цикл while добавлен в программу не просто так.
ты ошибку публикуй, а не плачь Ярославны.
да оперный же кабан! ТЕКСТ ОШИБКИ. "Имя сетра, имя!" (с)
нет больше ничего
это и есть текст
тыц
нет больше ничего
это и есть текст
файл/ настройки/ Показать подробный вывод - отметь Компиляция.
отметь
отнють
отметь
отнють
Хотя, казалось бы?
wdrakula
спасибо!
всё получилось
Жесть — холоднокатаная отожжённая листовая сталь толщиной 0,10—1,2 мм с нанесёнными защитными покрытиями из олова или специальными покрытиями, напр. лаком, цинком, хромом и другие. Выпускается в листах размерами 512–1000 × 712–1200 мм или в рулонах шириной до 1 м, массой до 15 тонн. (источник)