Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd (8 , 9 , 4 , 5 , 6 , 7) ;
- void setup (){
- Serial.begin(9600) ;
- lcd.begin (16 ,2) ;
- randomSeed( 3 ) ;
- }
- char rndChar(){
- switch(random (1,4)){
- case 1: return random (48, 57);
- break;
- case 2: return random (65, 90);
- break;
- case 3: return random (97, 122);
- break;
- default:
- Serial . println ( "greskaUrandChar" );
- }}
- char* rndString(char* str, int sSize){
- int i = 0;
- for(i = 0; i < sSize; i++) str[i] = rndChar();
- str[sSize - 1] = '\0';
- return str;
- }
- #define DUZINA_RAND 5
- char randString[DUZINA_RAND];
- char string [64]; //bafer u koji se smesta primljeni string
- int duzina ;
- void loop () {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd . print (rndString(randString, DUZINA_RAND)) ;
- while (!Serial.available()) ;
- delay (100);
- duzina = Serial.available() ;
- Serial.readBytes(string,duzina) ;
- string[duzina] = 0;
- lcd.setCursor(0, 2);
- if(NULL != strstr(string, randString))lcd.print ("HUMAN");
- else lcd.print ("BOT") ;
- delay (1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement