Go Down

Topic: fingerprint scanner communication through uart (Read 14196 times) previous topic - next topic


drab

ok i changed char incomingByte[11] to byte incomingByte[11] was that correct..? and i also changed my for statement to

for(byte i=0; i<11;i++){}
          {
            incomingByte = fdk.read();
         }   
       }
now the only error im getting is that incompatible types in assignment of int to byte[11]

AWOL

Yes, that's quite an understandable error.
Which element of the array did you want to put the most recently-read character?

drab

I want the bits to go from 0 to 11 in the order they are read i think so i only have to  compare the 5th spot in the array and once it fills that spot and gets its match or no match its goes on and sets a pin high as well as other things

AWOL

No, you want the bytes that go from zero to ten

drab

ok so how do i get them and where is my mistake at ive seen lots of other code that has done what im trying to do and still cant figure out where im making my mistake at my teacher i had for programming has no clue at all so im stuck in the proverbial mud here....im learninng more here than i did in class and would love to have that lightbulb moment....


AWOL

Reply #26  looked to be going in the right direction, it was just missing a declaration of an index.

drab

ok what do you mean by a decleration of an index? what should i be indexing??? or where should i be indexing...

AWOL

The index is "i", and you didin't declare it.

drab

wow i just got it to compile.....heres what it looks like now

Code: [Select]
#include <NewSoftSerial.h>
#include <string.h>
NewSoftSerial fdk(2, 3);
int ledPin = 13;
byte incomingByte[10];
byte array1[]={
  0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x13, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};
byte array2[]={
  0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x10, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};
byte array3[]={
  0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x12, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};
byte array4[]={
  0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x11, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};


void setup() 
{
  Serial.begin(9600);
  fdk.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
}

void loop()
{
  if (fdk.available() >=10 )
  {

    for(byte i=0; i<10;i++){
    }
    {
      incomingByte[10] = fdk.read();
    }   
  }
  if(incomingByte[5]==array1[5])
  {
    digitalWrite(13,HIGH);
  }
}


as you can see on on the line incomingByte[10] = fdk.read(); i added my array value.....and thats what allowed it to compile. is that the index you was talkin about awol? if so then i see what you was getting at.... but when i uploaded it all i got was an autoscrolling F in my serial monitor after i added the serial.print command....

AWOL

Code: [Select]
incomingByte[10] = fdk.read();
...will overwrite the same eleven times.

The index should be "i", not "10".

PaulS

Quote
The index should be "i", not "10".

And, the assignment should be in the body of the for loop, not in a separate (useless) block after the for loop.
The art of getting good answers lies in asking good questions.

michael_x

Quote
assignment should be in the body of the for loop

indentation and the correct number of open/closed braces is fine, but not always sufficient ;)

PaulS

Quote
and the correct number of open/closed braces

That depends on how you define "correct". If "correct" is simply the same number of each, then the number of curly braces in that code is correct.

If "correct" also includes only necessary (and optional, but highly recommended), then the number of curly braces in that code is not correct.
The art of getting good answers lies in asking good questions.

michael_x


Go Up