


SteeringCircle.y = 60 + sine(joystick.joy1_y2*180/250+90) * radius/2 ĭrawCircle(steeringCircle.x,steeringCircle.y,20) Let's add some statements to be executed if the "top hat" is not selected.Īdd the following to the default: case in the first switch block.ĭrawCircle(powerCircle.x,powerCircle.y,radius)

Notice that lonely default: in the first switch block. Typedef struct circle_struct Now that you have all of the buttons working. Also the code below will create two definitions for trigonometry functions. *!!Code automatically generated by 'ROBOTC' configuration wizard !!*//Then add a few more helper functions shown below which will create an object type to create coordinate variables that will be used in circles. #pragma config(Motor, motorC, C, tmotorEV3_Large, PIDControl, encoder) #pragma config(Motor, motorB, B, tmotorEV3_Large, PIDControl, encoder) #pragma config(Sensor, S4, ultrasonicSensor, sensorEV3_Ultrasonic) #pragma config(Sensor, S3, colorSensor2, sensorEV3_Color) #pragma config(Sensor, S2, colorSensor1, sensorEV3_Color) } #pragma config(Sensor, S1, touchSensor, sensorEV3_Touch) Start RobotC then click on the New File button from the button bar. If you want to configure the Ultrasonic sensor on port 4, call it: ultrasonicSensor When configuring color sensor on port 3, just give it the name "colorSensor2". When configuring color sensor on port 2, just give it the name "colorSensor1". When configuring touch sensor on port 1, just give it the name "touchSensor". When configuring motor C, just give it the name "C". When configuring motor B, just give it the name "B". Configure two light sensors on ports 2 and 3 and a touch sensor on port 1. Go to the Motors and Sensors setup and configure two motors: B and C. Follow them in order-so that you'll know what to do when you have to write your own programs some day.

Try not to just jump to the end of the lesson and copy the whole program. You will write a program according to the instructions below. This exercise requires you to be in front of a computer with RobotC and a Mindstorms robot. The goal of this exercise is to be able to create the necessary functions to control a robot using the joystick. Playbook: Joystick Programming - The Exercise Purpose: Learning how to program based on input from devices.
