Go Down

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

drab

Is for a school project so i didnt pay for it but i would though cause theres tons u can do with it and its the only stand alone out there to integrate into projects

drab

ok set me up a byte array and now when i make my if statement to compare the incoming data to the array i get a invalid use of member (did you forget the & ?) and also expected identifier before != token and also a primary-expression befor != token

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


void setup() 
{
  Serial.begin(9600);
  fdk.begin(9600);
}

void loop()
{
  if (fdk.read == array1, && != array2 && != array3 && !=array4)
  {
    digitalWrite(13,HIGH);
  }
  else
  digitalWrite(12,HIGH);
}

AWOL

fdk.read is a pointer to a function; it is never in a month of Sundays going to be equal to a pointer to RAM.
You need to read all the input, the compare your two arrays a byte at a time

drab

and how would i go about doing that i guess is where im lost now

AWOL

Some hints in reply #7.

Have you worked through any of the examples supplied with the IDE?

drab

yes i have and im not really getting anywhere sorry to say

michael_x


You need to read all the input, then compare your two arrays a byte at a time


If you show your tries, tell what you expect and what you get instead, you sure get more specific hints.

I hope no one will do that school project for you ;)

drab

#22
May 17, 2012, 10:34 pm Last Edit: May 17, 2012, 10:37 pm by drab Reason: 1
im not wanting anyone to do it for me just a lil help understanding what im not doing right....
i got this to compile and upload but wont light my led for either conditon and the only value that changes on the incoming bytes is the 6th place value..
Code: [Select]
#include <NewSoftSerial.h>
#include <string.h>
NewSoftSerial fdk(2, 3);
const int led = 13;
byte array1[]={0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x13, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};
byte array2[]={0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x12, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};
byte array3[]={0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x11, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};
byte array4[]={0xFF, 0xFF, 0xFF, 0xF5, 0xC0, 0x10, 0x0E, 0xFF, 0xFF, 0xFF, 0xF5};


void setup()  
{
 Serial.begin(9600);
 fdk.begin(9600);
}

void loop()
{
 if (fdk.read()== array1[6])
  {
   
   digitalWrite(13,HIGH);
 }
 else
 digitalWrite(12,HIGH);




AWOL

No, you really need to go back to basics and check how to read a sequence (hint) of bytes from a serial port.

drab

you use the code

Code: [Select]
if (fdk.available() > 0){
    incomingByte = fdk.read();

to do that correct?? and then i need to create an array to put that in correct or can i just compare it to my array i have made already

michael_x

This reads 1 byte ( starting with the 0xFF, probably ). The other bytes will arrive later
The loop() function typically was run a couple of times, not doing anything special .

You either do nothing until all expected bytes have arrived ( fdk.available() >= 11) and then read them, using a little for ( ) { } sequence into an array,
or you read them as they arrive and "remember" in a global or static variable, where in the sequence you are.
With that position variable, you can immediately check if the read byte is the expected one at that position.



drab

#26
May 18, 2012, 05:26 am Last Edit: May 18, 2012, 05:56 am by drab Reason: 1
Code: [Select]
ok michael, something kinda like this with the for loop

[code if (fdk.available() >=11 ){
   
   for(i=0; i<11;i++){
     incomingByte[i] = fdk.read();]


i hope this is closer than i have been....only problem is when i use it in the full sketch as followes i get error 'i' was not declared in this scope in the loop
Code: [Select]
#include <NewSoftSerial.h>
#include <string.h>
NewSoftSerial fdk(2, 3);
int ledPin = 13;
char incomingByte[11];
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() >=11 )
{
   
   for(i=0; i<11;i++){}
{
     incomingByte[i] = fdk.read();
   }  
 }
}

as you know i want the incoming serial in an array so i can compare one value of the data for a match

PaulS

So, where did you declare i to be a variable? I don't see that you did.

for(int i=0; i<11; i++)
The art of getting good answers lies in asking good questions.

drab

you are correct paul i guess i did not declare it......so i guess ill do that...but should i declare it as an int or char seing as its a hex value or would it be a byte

PaulS

Quote
but should i declare it as an int or char seing as its a hex value or would it be a byte

0 is not a hex value. 11 is not a hex value. The range of values that i can have would fit in a byte, so you could use byte. char is not appropriate. The array index is not a character.
The art of getting good answers lies in asking good questions.

Go Up