nomadgogreen.blogg.se

Robotc multitasking
Robotc multitasking













robotc multitasking
  1. ROBOTC MULTITASKING UPDATE
  2. ROBOTC MULTITASKING CODE

(People who think they can multitask by texting while driving are dangerously wrong.)Ī much simpler approach works if the robot doesn't need to run the bumper/motor control loop while flashing the LEDs, that is, if it doesn't mind being unresponsive to the bumpers while flashing the LEDs for 1 second. There are alternatives for the tracking variables, such as 3 separate variables for whether it's currently flashing, which of the 7 flash cycles it's currently doing, whether it's in the ON or OFF phase of that cycle, and the clock reading.Īpproach #2 is trickier because doing two things at once is tricky. The simplest tracking variable would be a counter from 0 (initial state) to 14 (doing the last LED "OFF" phase) and the value of the system clock from the last change, to let you detect when the clock is 71 msec later than that. turn off and set the tracking variables back to the initial state after 14 of those steps. The steps are: turn on the LEDs when it was in the initial state and the light sensor is above-threshold, turn off the LEDs when it's 1/14 of a second later, turn on the LEDs when it's 1/14 of a second later.

robotc multitasking

ROBOTC MULTITASKING UPDATE

Each cycle around the main loop, use if statements to check those variables, do the next step in the flash-LED cycle if it's time, and update those variables. Use variables to track the sequencing through the flash-LED loop.Or, you could use wait1Msec(71) to wait 71 msec, which is about 1/14 second. I wrote that as 1.0/14.0 rather than 1/14 because many programming languages compute 1/14 in integer math, yielding 0, while 1.0/14.0 uses floating point math. That way, 7 cycles around the loop will take 7 * (1/14 + 1/14) = 1.0 seconds. While (SensorValue(bumpSwitch) = 0 & SensorValue(bumpSwitch2) = 0). #pragma config(Motor, port10, rightMotor, tmotorVex269, openLoop) RobotC Tutorial Packet II Storming Robots Computational Thinking and Engineering 3.3 MULTITASKING A task is a module which runs simultaneously with other tasks. #pragma config(Motor, port1, leftMotor, tmotorVex269, openLoop) #pragma config(Sensor, dgtl11, ledRed, sensorLEDtoVCC) #pragma config(Sensor, dgtl10, ledGreen, sensorLEDtoVCC) #pragma config(Sensor, dgtl4, bumpSwitch2, sensorTouch) In reality, however, you're less productive, and the quality of your work. According to neuroscience research, trying to do two tasks at once makes you feel more productive. Even if you think you're good at it, research shows you're fooling yourself. The problem is that multitasking is a myth.

robotc multitasking

#pragma config(Sensor, dgtl3, bumpSwitch, sensorTouch) The myth of multitaskingand how robots can help.

ROBOTC MULTITASKING CODE

My Code is posted below: #pragma config(Sensor, in2, lightSensor, sensorReflection) While the bump switch code block is running, I need the LEDs to light up and go off seven times for one second every time the Light sensor value gets higher than 400. The problem I'm having is getting the LEDs to light up correctly. I need to get my robot to be able to use the bump switches so that either one can be pressed and the motor corresponding to that bumpswitch will run for as long as the bump switch is pressed.















Robotc multitasking