So my senior mechanical engineering group is converting a hobby CNC setup to play Jenga. We are identifying each block with a unique RFID tag. We have spent the past 2 days trying to debug the scanner to move across a row of blocks and store the tag identifyer in an array as it reads. The two main issues are: 1) The scanner does not read the tags which moving across the row. 2) The scanner beeps, but prints 0 values to the serial monitor. Any help is much appreciated as this is due on Saturday. We're all guaranteed A's for effort, but we'd sure as hell like to get it to work. Thanks! Heres the relative code:
digitalWrite(xAxisDir, LOW);
tone(xAxisMotor, 500, 7000);
milliSeconds = millis() + 10000; //waiting for tone to end
delay(2000); //waiting to reach tag range of 1st block
tagCheck = myrfid.decodeTag(tagData);
for (int j = 0; j < 3; j++){
if (tagCheck == true){
digitalWrite(buzzer, HIGH);
delay(100); //time for buzzer to sound
towerArray[row][j] = tagData[4];
}
while(millis() < milliSeconds); //do nothing while waiting for tone to finish
So? The for loop accomplishes nothing if tagCheck is false. Testing tagCheck on every iteration of the loop is silly. Check it ONCE:
if (tagCheck == true)
{ // Down here where it belongs
for (int j = 0; j < 3; j++)
{
digitalWrite(buzzer, HIGH);
delay(100); //time for buzzer to sound
towerArray[row][j] = tagData[4];
}
}
So, why are you storing the same piece of information in 3 elements of the towerArray array?
Does Array REALLY need to be in the name of the variable? Don't the square brackets tell you that the variable is an array?