The Test Bed
This is the setup we used for our testbeds. The components included are: 2 wire motors, 1 servo motor, a flashlight, a line follower, a light sensor, a potentiometer, a limit and bump switch, an optical shaft encoder, an ultrasonic sensor, and a green LED. We were tasked to write code in the program ROBOTC for VEX to fufil certain functions and learn how to code. Here are 2 examples of the programs we wrote, and what real life applications each serve in everyday life.
Codes
In this part of our work on the test bed, we were tasked with creating a program that would make the bump switch, when pressed, to turn on the left motor, and the limit switch, when pressed, to turn on the right motor. Since the buttons need to be pushed multiple times, we used Boolean Logic to create an infinite loop [while(1==1)]. From there, we went on to assign each sensor to each motor by using if/else statements. Finally, we made sure if the switches weren't pressed, the motor that was linked to the certain switch wouldn't turn. This type of code is important when you want a specific object to work without the rest of the parts to go off as well. For example, if you were to unlock your car via your keys remotely and the car turned on, your headlights went on, and your windsheild wipers were going. This kind of code allows your car to know only to unlock the car when the button on your key is pressed. It also allows your car to know what to do when certain buttons are activated.
In this program, we incorperated variables into our code. By using the variable n , we were able to make the test bed repeat a program a finite number of times. To start off, we started by indentifying the variable n and defining it's value to begin at 0. As the program was carried out by the robot, the variable's value increased by one. The program then stopped after 5 times due to the while statement saying the program would repeat until n<5. This applies to certain functions that need to be done a certain amount of times. If a factory want to make only 100 bottles, the machine can be told to carry out making bottles until it has made 100. Since the process is reliant on how many bottles were made rather than how long, the factory is more precise and doesn't waste money creating extra or not enough product.