Now that you have successfully accepted the first green disk, you will now code any additional green disks to be rejected. To do this, a tracking system needs to be established to track if the first green disk has already been accepted.
A variable will be used to establish this tracking system. Variables were introduced in Lab 5 and are used to store values in a project. A Boolean variable is a special type of variable that stores one of two values - either true or false.
In this project, you will create a Boolean variable to store true and false values to track when the first green disk has been accepted.
This allows any other green disks introduced via the Disk Feeder to be rejected and diverted off of the exit conveyor.
You will now create the greenAccepted Boolean variable that you will use in your 'Lab 11- Disk Feeder' project.
In VEXcode V5, follow the steps in this video to create the greenAccepted Boolean variable.
Because the project will start by accepting the first green disk, the Boolean variable is set to ‘true.’
Follow the steps in this video to set the greenAccepted Boolean variable to 'true' at the beginning of the project.
For Your Information
The [If then else] block runs the blocks inside the first or second branch based on the Boolean value reported.
If the Boolean condition is reported as true, the blocks inside of if section will be run.
If the Boolean condition is false, the blocks inside of else section will be run.
To be able to distinguish if the green disk that is dispensed should be accepted or rejected, an [If then else] block will be needed.
The if branch of the [If then else] block will run when the greenAccepted Boolean variable is 'true.'
Follow the steps in this video to add the [If then else] block.
The branch of the [If then else] block runs depending on the true or false value of the Boolean condition.
Follow the steps in this video to set the greenAccepted Boolean variable as the condition of the [If then else] block.
After the first green disk is accepted, the greenAccepted variable must be set to 'false' to indicate that no additional green disks will be accepted.
Follow the steps in this video to set the condition of the [If then else] block and to set the greenAccepted Boolean variable to 'false.'
Load three green disks into the Disk Feeder and download and run the project.
The first green disk will be accepted and then the greenAccepted Boolean variable will be set to 'false.'
Once the green disk has stopped in front of the pickup sensor, stop the project and check in with your teacher.
If the green disk did not follow the path shown, notify your teacher during the check in.