Hi everyone. My question is same title. Yes problem when compile. Please help me.
This is a code of my program (in CPP):
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "lcd_i2c_quotes/lcd_i2c.h"
#include "hardware/timer.h"
#include "keypad/pico_keypad4x4.h"
#include <cstddef>
using namespace std;
LCDI2C lcd(0x27 , 2, 16, 16, 17, 0);
#define sifra 7
int pos = 0;
char Data[sifra];
char Master[sifra] = "123456";
int data_count = 0, master_count = 0;
bool Pass_is_good;
char customKey;
uint columns[4] = { 18, 19, 20, 21 };
uint rows[4] = { 10, 11, 12, 13 };
char matrix[16] = {
'1', '2' , '3', 'A',
'4', '5' , '6', 'B',
'7', '8' , '9', 'C',
'*', '0' , '#', 'D'
};
bool vrata = true;
#define bravica 16
int bravica_value = 0;
int main()
{
stdio_init_all();
gpio_init(bravica);
gpio_set_dir(bravica, GPIO_OUT);
bravica_value = 0 - bravica_value;
gpio_put(bravica, bravica_value);
lcd.init();
lcd.lcd_clear();
lcd.lcd_string("UKI COMPUTERS");
lcd.lcd_set_cursor(0, 1);
lcd.lcd_string("--Wait--");
sleep_ms(3000);
lcd.lcd_clear();
return 0;
}
void Open()
{
lcd.lcd_set_cursor(0, 0);
lcd.lcd_string(" Enter Password");
customKey = pico_keypad_get_key();
if (customKey)
{
Data[data_count] = customKey;
lcd.lcd_set_cursor(data_count, 1);
lcd.lcd_string(Data);
data_count++;
}
}
void clearData()
{
while (data_count != 0)
{
Data[data_count--] = 0;
}
return;
}
int loop()
{
if (vrata== 0)
{
pico_keypad_init(columns, rows, matrix);
char customKey;
customKey = pico_keypad_get_key();
if (customKey == '#')
{
lcd.lcd_clear();
bravica_value = 1 - bravica_value;
gpio_put(bravica, bravica_value);
lcd.lcd_string(" Door is close");
sleep_ms(3000);
vrata= 1;
}
while(1){
tight_loop_contents();
}
}
else Open();
if (data_count == sifra - 1)
{
if (!strcmp(Data, Master))
{
lcd.lcd_clear();
bravica_value = 0 - bravica_value;
gpio_put(bravica, bravica_value);
lcd.lcd_string(" Door is Open");
vrata= 0;
}
else
{
lcd.lcd_clear();
lcd.lcd_string(" Wrong Password");
sleep_ms(1000);
vrata= 1;
}
clearData();
}
}
I'am used a library from GitHub. This is link:
https://github.com/OSWA00/pico-keypad4x4
And i'am for lcd libary used from pico-examples i2c/lcd_i2c_quotes.
When i'am compile a code this error shows to me (after all):
c:/progra~2/gnuarm~1/102021~1.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/keypad.dir/C_/Compilers/pico/pico-sdk-master/src/rp2_common/pico_standard_link/crt0.S.obj: in function `__get_current_exception':
(.reset+0x9c): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [blink\keypad\CMakeFiles\keypad.dir\build.make:823: blink/keypad/keypad.elf] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1466: blink/keypad/CMakeFiles/keypad.dir/all] Error 2
mingw32-make: *** [Makefile:90: all] Error 2
How to reslove this error? Please help me.
What I have tried:
I'am tried all things. I'am same don't know what to do. Again please help me and thanks advance.