Card reader update

If you follow me on Facebook or Google+ then you probably now that I’m building a card reader.

Program is done for the card reader part – it doesn’t actually know what the card reads – It just knows if it’s the correct card or not, so it would need to be completely reprogrammed to accepted different colors or order of colors – I attempted to make one that read card then figure out if it is correct after but it was not working correctly. I’m not entirely sure what i’m going to use this for yet – I was thinking of  making a car that only worked after the card was scanned, but I’ve been having trouble building a car around this.
It was all coded in ROBOTC.
Pictures below the code.
You can download this code here.

#pragma config(Sensor, S1,     Touch,          sensorTouch)
#pragma config(Sensor, S2,     Power,          sensorTouch)
#pragma config(Sensor, S3,     Color,          sensorCOLORFULL)
#pragma config(Motor,  motorA,          Cardmover,     tmotorNXT, PIDControl, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
task main()
{
	nxtDisplayCenteredBigTextLine(2, "Remove");
	nxtDisplayCenteredBigTextLine(4, "Card");
	while(SensorValue(Power) == 0)
	{
		motor[motorB] = runStateHoldPosition;
		motor[motorC] = runStateHoldPosition;
		while(SensorValue(Touch) == 1)
		{
			motor[Cardmover] = -100;
			wait10Msec(10);
	  	PlayTone(758, 2);
		}
		motor[Cardmover] = 0;
		motor[Cardmover] = 0;
		eraseDisplay();
		nxtDisplayCenteredBigTextLine(2, "Insert");
		nxtDisplayCenteredBigTextLine(4, "Card");
		while(SensorValue(Touch) == 0)
		{
		}
		eraseDisplay();
		motor[Cardmover] = 75;
		while(SensorValue(Color) == BLACKCOLOR)
		{
		}
		if(SensorValue(Color) == REDCOLOR)
		{
			while(SensorValue(Color) == REDCOLOR)
			{
			}
			if(SensorValue(Color) == WHITECOLOR)
			{
				while(SensorValue(Color) == WHITECOLOR)
				{
				}
				if(SensorValue(Color) == YELLOWCOLOR)
				{
					while(SensorValue(Color) == YELLOWCOLOR)
					{
					}
					if(SensorValue(Color) == WHITECOLOR)
					{
						while(SensorValue(Color) == WHITECOLOR)
						{
						}
						if(SensorValue(Color) == REDCOLOR)
						{
							nxtDisplayCenteredTextLine(2, "Access Granted");
							motor[Cardmover] = -100;
						 	wait10Msec(200);
						 	motor[Cardmover] = 0;
						 	while(SensorValue(Touch) == 1)
							{
								motor[Cardmover] = -100;
								wait10Msec(10);
						  	PlayTone(758, 2);
							}
							motor[Cardmover] = 0;
					 	}
					 	else
						{
							  nxtDisplayCenteredTextLine(3, "access denied");
							  	motor[Cardmover] = -100;
							 	wait10Msec(200);
							 	motor[Cardmover] = 0;
								}
							 	}
							 	else
							 	{
							   nxtDisplayCenteredTextLine(3, "access denied");
							   	motor[Cardmover] = -100;
							 		wait10Msec(200);
							 		motor[Cardmover] = 0;
							 		}
						 			}
						 			else
							 		{
							   	nxtDisplayCenteredTextLine(3, "access denied");
							   	motor[Cardmover] = -100;
							 		wait10Msec(200);
							 		motor[Cardmover] = 0;
							 		}
							 		}
							 		else
							 		{
							   		nxtDisplayCenteredTextLine(3, "access denied");
							   		motor[Cardmover] = -100;
							 			wait10Msec(200);
							 			motor[Cardmover] = 0;
							 		}

					}
	}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s