yo9dl Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Incerc sa incarc schita de aici - https://pa3csg.nl/?page_id=68 - in Arduino Nano, dar imi apare eroarea ‘POSITIVE’ was not declared in this scope. Am folosit o multime de biblioteci (inclusiv cate o singura biblioteca in folderul Arduino sa nu apara conflicte), dar in zadar. Exemplele "hello world" functioneaza fara nicio problema, mai putin acesta (https://forum.hwkitchen.cz/viewtopic.php?t=2439) #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); void setup() { lcd.begin(16, 2); lcd.print("hello world"); } void loop() { } Sunt depasit de situatie si sunteti ultima mea speranta. Link spre comentariu
djlove Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Poti pune un printscrren direct din Arduino sa apara textul color acolo unde e cazul? Ai incarcat libraria utilizata in Arduino?, nu e de ajuns sa o copezi undeva..... Sketch -> Include Library -> Add zip library -> si apoi selectezi unde ai libraria salvata in format .zip Link spre comentariu
yo9dl Postat Iunie 28, 2022 Autor Partajează Postat Iunie 28, 2022 Librariile sunt instalate, am verificat acum in Library Manager. Iata eroarea Link spre comentariu
zvonacfirst Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 De ce nu pastrezi adresarea pinilor pentru I2C din skecthul care iti functioneaza? De exemplu acesta: #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { lcd.begin(); lcd.backlight(); lcd.print("hello world"); } void loop() { } Link spre comentariu
nico_2010 Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Salut, eroarea pe care o primesti este din cauza folosirii gresite a librariei LiquidCrystal_I2C.h. Mai precis: LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); --> asta nu exista in libraria LiquidCrystal_I2C si nici in libraria LiquidCrystal Daca folosesti un afisor LCD tip16x2 si are adaptorul I2C cu PCF8574(A) corect ar fi fost: LiquidCrystal_I2C lcd(0x27, 16,2); Daca in schimb folosesti acelasi tip de afisor dar fara adaptorul I2C, corect ar fi sa folosesti asta: #include <LiquidCrystal.h> LiquidCrystal lcd(12/*RS*/, 11/*EN*/, 5/*D4*/, 4/*D5*/, 3/*D6*/, 2/*D7*/);//pinul RW este conectat la masa (GND) Incearca sketch-ul modificat de mai jos si spune daca iti functioneaza: /* Kenwood Bandecoder !!! Warning this version was tested only with TS-590 in standalone mode !!! Please let me know, if works also with other radios.... Tested with: TS-590 Should work with: TS-480, TS-990 and TS-2000 by Ondrej Kolonicny OK1CDJ, <span id="cloak41725"><a href="mailto:[email protected]">[email protected]</a></span><script type="text/javascript"> //<!-- document.getElementById('cloak41725').innerHTML = ''; var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy41725 = 'ondra' + '@'; addy41725 = addy41725 + 'ok1cdj' + '.' + 'com'; document.getElementById('cloak41725').innerHTML += '<a ' + path + '\'' + prefix + ':' + addy41725 + '\'>' + addy41725+'<\/a>'; //--> </script>, Enric EA3NR http://www.remoteqth.com you can get KIT here: http://hamshop.cz/remoteqth-com-c29/stavebnice-band-dekoderu-s-arduino-i230/ Change log: I, PA3CSG, modified the unit for standard available relay boards from China / Ebay. I also added an I2C LCD display on A4 and A5, saving a lot of wiring for the leds. v 1.1.4 9.1.2014 - chages by EA3NR TNX If the radio is powered off and the band decoder remains powered on, the band decoder output remains indefinitely showing the last selected band and never goes out of this status... It happens also if you power the radio off and then you power the radio on immediately. v 1.1.3 17.2.2014 - added 29 MHz and 51 and 52 MHz as 10m and 6m output TNX to Adam OK2IPW v 1.1.2 19.1.2014 - solved bug in BCD output TNX to Frank - IZ4YDF v 1.1.1 10.12.2O13 - minor change in serial comunication, now is source tested also with TS-590 v 1.1 13.9.2013 - added BCD output like in YAESU RADIO to connect another accessories WARNING - only standard bands like 80,40,20,15,10 are suported on other bands are all BCD pins in low state v 1.0 - 20.3.2013 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <Wire.h> #include "LiquidCrystal_I2C.h" /*-----( Declare Constants )-----*/ /*-----( Declare objects )-----*/ // set the LCD address to 0x27 for a 16 chars 2 line display // A FEW use address 0x3F // Set the pins on the I2C chip used for LCD connections: // addr, en,rw,rs,d4,d5,d6,d7,bl,blpol LiquidCrystal_I2C lcd(0x27, 16,2); // Set the LCD I2C address // uncomment next line if band decoder is connected alone to the radio and not sniffing comunication #define ALONE_MODE // YAESU BCD /* A B C D dec 160 1 0 0 0 1 80 0 1 0 0 2 40 1 1 0 0 3 20 1 0 1 0 5 15 1 1 1 0 7 10 1 0 0 1 9 */ // IO port definition for BCD output int D=12; int C=13; int B=A0; int A=A1; // IO port definition for bands int b160 = 9; int b80 = 8; int b40 = 7; int b30 = 6; int b20 = 5; int b17 = 4; int b15 = 3; int b12 = 2; int b10 = 11; int b6 = 10; // variables char inByte; // incoming byte from serial RX String buffer = ""; // empty string to store incoming serial data -- a buffer boolean stringComplete = false; // whether the string is complete or not // Setup procedure void setup() { lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight lcd.setCursor(4,0); //Start at character 4 on line 0 lcd.print("Welcome!"); lcd.setCursor(5,1); lcd.print("PA3CSG"); delay(2000); lcd.clear(); Serial.begin(9600); // setup serial speed buffer.reserve(64); // reserve 64 bytes for the incoming data buffer; UARTS's buffer is only 64 bytes long... :-P pinMode(b160, OUTPUT); pinMode(b80, OUTPUT); pinMode(b40, OUTPUT); pinMode(b30, OUTPUT); pinMode(b20, OUTPUT); pinMode(b17, OUTPUT); pinMode(b15, OUTPUT); pinMode(b12, OUTPUT); pinMode(b10, OUTPUT); pinMode(b6, OUTPUT); pinMode(A, OUTPUT); pinMode(B, OUTPUT); pinMode(C, OUTPUT); pinMode(D, OUTPUT); } void loop() { //print things that donnot change anymore lcd.setCursor(13,0); lcd.print("KHz"); lcd.setCursor(0,1); lcd.print("Antenna:"); // send request for frequency only when bandecoder is connected alone to the radio #ifdef ALONE_MODE Serial.print("IF;"); // wait for the transmission of outgoing serial data from the Arduino to the radio to be completed Serial.flush(); // we don't have to be always polling the radio frequency... we can wait for a while...XD delay(100); #endif if (Serial.available() > 0 ) { // get the first byte inByte = (char) Serial.read(); // when the first byte is 'I' then we have to continue reading the input data if (inByte == 'I') { buffer += inByte; while (Serial.available() > 0) { inByte = (char) Serial.read(); buffer += inByte; // the reading procedure finishes when we read the ';' character if (inByte == ';') { stringComplete = true; } } } // update band output only if the complete data has been received if (stringComplete) { writeBand(); // clear the RX buffer buffer = ""; stringComplete = false; } } } void writeBand() { String str_if = buffer; String qrg ; // tady je kmitocet od 5 do 10 znaku qrg = str_if.substring(5,10); //na tretim miste ma byt 1 pak do jde na HIGH // 160m band if ((qrg[0] == '0')&&(qrg[1] == '1')) { digitalWrite(b160, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, LOW); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print("160M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 80m band if (qrg[1] == '3') { digitalWrite(b80, LOW); digitalWrite(b160, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 80M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 40m band if (qrg[1] == '7') { digitalWrite(b40,LOW); digitalWrite(b80, HIGH); digitalWrite(b160, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 40M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 30m band if ((qrg[0] == '1')&&(qrg[1] == '0')) { digitalWrite(b30, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b160, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, HIGH); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 30M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 20m band if ((qrg[0] == '1')&&(qrg[1] == '4')) { digitalWrite(b20, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b160, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, HIGH); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 20M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 17m band if ((qrg[0] == '1')&&(qrg[1] == '8')) { digitalWrite(b17, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b160, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 17M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 15m band if ((qrg[0] == '2')&&(qrg[1] == '1')) { digitalWrite(b15, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b160, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, LOW); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 15M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 12m band if ((qrg[0] == '2')&&(qrg[1] == '4')) { digitalWrite(b12, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b160, HIGH); digitalWrite(b10, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, LOW); digitalWrite(D, HIGH); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 12M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } // 10m band if (((qrg[0] == '2')&&(qrg[1] == '8'))||((qrg[0] == '2')&&(qrg[1] == '9'))) { digitalWrite(b10, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b160, HIGH); digitalWrite(b6, HIGH); digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, LOW); digitalWrite(D, HIGH); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 10M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("HF"); } //6m band if ((qrg[0] == '5')&&(qrg[1] == '0')) { digitalWrite(b6, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b160, HIGH); digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, HIGH); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" 6M"); lcd.setCursor(6,0); lcd.print(" "); lcd.setCursor(7,0); lcd.print(qrg); lcd.setCursor(9,1); lcd.print(" "); lcd.setCursor(9,1); lcd.print("VHF"); } if ((qrg[0] == '5')&&(qrg[1] == '1')) { digitalWrite(b6, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b160, HIGH); digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, HIGH); } if ((qrg[0] == '5')&&(qrg[1] == '2')) { digitalWrite(b6, LOW); digitalWrite(b80, HIGH); digitalWrite(b40, HIGH); digitalWrite(b30, HIGH); digitalWrite(b20, HIGH); digitalWrite(b17, HIGH); digitalWrite(b15, HIGH); digitalWrite(b12, HIGH); digitalWrite(b10, HIGH); digitalWrite(b160, HIGH); digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, HIGH); } } Link spre comentariu
yo9dl Postat Iunie 28, 2022 Autor Partajează Postat Iunie 28, 2022 Am incarcat varianta propusa, dar pe afisaj nu apare nimic. Link spre comentariu
nico_2010 Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Care varianta? Ce fel de afisor folosesti, cu sau fara adaptor I2C? Link spre comentariu
yo9dl Postat Iunie 28, 2022 Autor Partajează Postat Iunie 28, 2022 Am instalat o singura librarie, se incarca dar nu afiseaza nimic. Am incarcat varianta propusa de tine. Afisajul nu stiu exact de care este (cumparat de la Optimus d...) si are I2C. Link spre comentariu
zvonacfirst Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Ai reglat contrastul? Link spre comentariu
nico_2010 Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Nu este asta libraria corecta. O gasesti in atasament. Afisorul se conecteaza pe pinii A4 (SDA) si A5(SCL) pentru comunicatie I2C. Dupa ce o instalezi ar trebui sa folosesti sketch-ul I2CSniffer si sa identifici ce adresa are adaptorul. Sketc-ul I2C Scanner/Sniffer: // -------------------------------------- // i2c_scanner // // Version 1 // This program (or code that looks like it) // can be found in many places. // For example on the Arduino.cc forum. // The original author is not know. // Version 2, Juni 2012, Using Arduino 1.0.1 // Adapted to be as simple as possible by Arduino.cc user Krodal // Version 3, Feb 26 2013 // V3 by louarnold // Version 4, March 3, 2013, Using Arduino 1.0.3 // by Arduino.cc user Krodal. // Changes by louarnold removed. // Scanning addresses changed from 0...127 to 1...119, // according to the i2c scanner by Nick Gammon // http://www.gammon.com.au/forum/?id=10896 // Version 5, March 28, 2013 // As version 4, but address scans now to 127. // A sensor seems to use address 120. // Version 6, November 27, 2015. // Added waiting for the Leonardo serial communication. // // // This sketch tests the standard 7-bit addresses // Devices with higher bit address might not be seen properly. // #include <Wire.h> void setup() { Wire.begin(); Serial.begin(9600); while (!Serial); // Leonardo: wait for serial monitor Serial.println("\nI2C Scanner"); } void loop() { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !"); nDevices++; } else if (error==4) { Serial.print("Unknown error at address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); } } if (nDevices == 0) Serial.println("No I2C devices found\n"); else Serial.println("done\n"); delay(5000); // wait 5 seconds for next scan } Apoi scrii adresa gasita de scanner in loc de 0x27 in : LiquidCrystal_I2C lcd(0x27, 16,2); LiquidCrystal_I2C.zip Link spre comentariu
yo9dl Postat Iunie 28, 2022 Autor Partajează Postat Iunie 28, 2022 Am incarcat libraria lui nico_2010, adresa I2C este 0x27, schita se incarca dar tot nu afiseaza nimic. Am incarcat din nou Hello world si este ok. Link spre comentariu
nico_2010 Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Sa recapitulam! Schita cu "Hello world" functioneaza, in sensul in care pe afisor apare textul cu pricina? Daca da, atunci conexiunile sunt corecte, afisorul functioneaza si problema este in sketch-ul pe care l-am postat (si pe care banuiesc ca vrei sa-l folosesti si tu). Am inteles bine? Link spre comentariu
nico_2010 Postat Iunie 28, 2022 Partajează Postat Iunie 28, 2022 Incearca cu sketch-ul de mai jos si spune daca functioneaza: #include <Wire.h> #include "LiquidCrystal_I2C.h" LiquidCrystal_I2C lcd(0x27, 16,2); void setup() { // put your setup code here, to run once: lcd.init(); // initialize the lcd lcd.init(); lcd.backlight(); lcd.setCursor(4,0); //Start at character 4 on line 0 lcd.print("Welcome!"); lcd.setCursor(5,1); lcd.print("PA3CSG"); } void loop() { // put your main code here, to run repeatedly: } Si ar trebui sa obtii asta: Link spre comentariu
yo9dl Postat Iunie 28, 2022 Autor Partajează Postat Iunie 28, 2022 Se pare ca functioneaza. Am inlocuit la schita postata de nico_2010, intuitiv, la plezneala de fapt, o linie de cod cu alte linii luate din Hello world. De fapt zvonacfirst mi-a sugerat ideea, dar nu m-am prins ce vrea sa zica. Nu inteleg mare lucru din chestiile astea dar am nevoie pentru anumite proiecte. Multumesc tuturor care s-au straduit sa ma ajute. yo9dl Link spre comentariu
Postări Recomandate
Creează un cont sau autentifică-te pentru a adăuga comentariu
Trebuie să fi un membru pentru a putea lăsa un comentariu.
Creează un cont
Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!
Înregistrează un nou contAutentificare
Ai deja un cont? Autentifică-te aici.
Autentifică-te acum