این کد را وارد می کنم و ارور expected ; before analogRead را می دهد.
کد HTML:#include <LCD4Bit_mod.h> // Create object to control an LCD. // Number of lines in display = 1 LCD4Bit_mod lcd = LCD4Bit_mod (2); // Key message char msgs [5] [15] = { "Right Key OK", "Up Key OK ", "Down Key OK ", "Left Key OK ", "Select Key OK"}; int adc_key_val [5] = {30, 150, 360, 535, 760}; int NUM_KEYS = 5; int adc_key_in; int key = -1; int oldkey = -1; void setup () { pinMode (13, OUTPUT); // we'll use the Debug LED to output a heartbeat lcd.init (); // Optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init () //lcd.commandWrite(0x0F);//cursor on, on display, Blink on. (Nasty!) lcd.clear (); lcd.printIn ( "KEYPAD testing ... pressing"); } void loop () { adc_key_in analogRead = (0); // Read the value from the sensor digitalWrite (13, HIGH); Key = get_key (adc_key_in); // convert into Key Press if (Key! = oldkey) // if KeyPress is detected { delay (50); // wait for debounce time adc_key_in analogRead = (0); // Read the value from the sensor Key = get_key (adc_key_in); // convert into Key Press if (key! = oldkey) { oldkey = key; if (key> = 0) { lcd.cursorTo (2, 0); // Line = 2, x = 0 lcd.printIn (msgs [key]); } } } // Delay (1000); digitalWrite (13, LOW); } // Convert ADC value to key number int get_key (unsigned int input) { int k; for (k = 0; k <NUM_KEYS; k ++) { if (input <adc_key_val [k]) { return k; } } if (k> = NUM_KEYS) k = -1; // No Valid Key pressed return k; }
اینم متن کامل
کد HTML:Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno" C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files\Arduino\hardware" -tools "C:\Program Files\Arduino\tools-builder" -tools "C:\Program Files\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files\Arduino\libraries" -libraries "C:\Users\Novin Pendar\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -ide-version=10607 -build-path "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Novin Pendar\Desktop\sketch_mar14a\sketch_mar14a.ino" C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files\Arduino\hardware" -tools "C:\Program Files\Arduino\tools-builder" -tools "C:\Program Files\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files\Arduino\libraries" -libraries "C:\Users\Novin Pendar\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -ide-version=10607 -build-path "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Novin Pendar\Desktop\sketch_mar14a\sketch_mar14a.ino" "C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\sketch\sketch_mar14a.ino.cpp" -o "nul" "C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod" "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\sketch\sketch_mar14a.ino.cpp" -o "nul" "C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod" "C:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod\LCD4Bit_mod.cpp" -o "nul" "C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod" "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\sketch\sketch_mar14a.ino.cpp" -o "nul" "C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod" "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\sketch\sketch_mar14a.ino.cpp" -o "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\preproc\ctags_target_for_gcc_minus_e.cpp" "C:\Program Files\Arduino\tools-builder\ctags\5.8-arduino5/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\preproc\ctags_target_for_gcc_minus_e.cpp" "C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod" "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\sketch\sketch_mar14a.ino.cpp" -o "C:\Users\NOVINP~1\AppData\Local\Temp\build4a90afdb235a8aa37750b97350cc3476.tmp\sketch\sketch_mar14a.ino.cpp.o" C:\Users\Novin Pendar\Desktop\sketch_mar14a\sketch_mar14a.ino: In function 'void loop()': sketch_mar14a:26: error: expected ';' before 'analogRead' adc_key_in analogRead = (0); // Read the value from the sensor ^ sketch_mar14a:28: error: 'Key' was not declared in this scope Key = get_key (adc_key_in); // convert into Key Press ^ sketch_mar14a:30: error: expected ')' before '!' token if (Key! = oldkey) // if KeyPress is detected ^ sketch_mar14a:33: error: expected ';' before 'analogRead' adc_key_in analogRead = (0); // Read the value from the sensor ^ sketch_mar14a:35: error: expected ')' before '!' token if (key! = oldkey) ^ sketch_mar14a:38: error: expected primary-expression before '=' token if (key> = 0) { ^ C:\Users\Novin Pendar\Desktop\sketch_mar14a\sketch_mar14a.ino: In function 'int get_key(unsigned int)': sketch_mar14a:61: error: expected primary-expression before '=' token if (k> = NUM_KEYS) ^ Using library LCD4Bit_mod in folder: C:\Users\Novin Pendar\Documents\Arduino\libraries\LCD4Bit_mod (legacy) exit status 1 expected ';' before 'analogRead'
این دو آدرس زیر کدهای خوبی برای شیلد ال سی دی دارن و لایبرری هم دارند
من کد را upload می کنم و دو چراغ tx و rx چند لحظه روشن میشه، بعداش شیلد lcd را بروی آردینو قرار می دم و باز هم همون عکسی که فرستادم فقط روشن میشه!!!!!
https://github.com/dzindra/LCDKeypad
Testing LCD Keypad Shield For Arduino | | Do It Easy With ScienceProg
هنوز مشکلم حل نشده!![]()
فایل زیر رو مطالع کنید :
http://www.robotshop.com/media/files...ki-dfr0009.pdf
بله مطالعه کردم و کد با لایبرری <LiquidCrystal.h> و <LCD4Bit_mod.h> را آپلود کردم، برد آردینو اوکی کار میکنه اما نمایشگر را که وصل می کنم چیزی نشان داده نمیشه، امیدوارم مشکل از کد باشه و شماره پینی که در کد وارد می کنیم، من تازه از آفتاب خریدم، پس چرا کار نمیکنه ... عکس را ضمیمه کردم ...
![]()
سلام دوستان
میشه لطفا من را راهنمایی کنید در پروژه ای که یک master , و 3 تا slave دارم. هر لحظه وضعیت slave تغییر می کند. چه جوری می تونم به شکل سریال اطلاعات slave ها را بخونم و دستور مناسب را برای انجام کار به آن ها از طریق master بگم. میشه لطفا کد های مربوطه را بگید. مرسی