Hi, I am currently doing a project with a VEX Cortex test bed using bump switch, potentiometer, light sensor, etc. There is coding needed for this project using PLTW Natural language, not blocks, but free written code. Right now we are doing a section on “if-else” coding. These are things that I need help coding with, (Thank you to anyone who can help me with this code)
Write a program that will do the following:
• Use the if-else command to program the green LED to turn on if the bumper switch is pressed,
and off if it’s released.
• Loop Forever.
Write a program that will do the following:
• Program a flashlight to come on only when the light sensor is covered.
• Loop forever.
Write a program that will do the following:
Four conditions:
a) When the bump switch is pressed, the left motor turns CW half speed
b) When the limit switch is pressed, the right motor turns CW half speed
c) When the light sensor is covered, the flashlight comes on
d) Everything is off
Loop forever.
Thank you so much! I had a quick question about my friend’s part of the code. This code should work, however we get a yellow X error with the words; Warning:Mismatched typedefs. Converting typedef ‘char’ to typedef ‘tSensors’, value ‘potentionmeter’
What is wrong with it?
while(1 == 1) //loop forever
{
if(bumpSwitch == 1) //button starts right motor
{
startMotor(rightMotor, 67);
}
if(limitSwitch == 1) //limit switch starts left motor
{
startMotor(leftMotor, -67);
}
else //if neither is pressed motor stops
{
stopMotor(rightMotor);
stopMotor(leftMotor);
}
}
It appears that the limit or bump switch is declared as a char type but is being used as a tSensor type. To fix this your friend should declare the limit switch and bump switch as a tSensor type instead of a char type.