| usingSystem.Collections; | |
| usingSystem.Collections.Generic; | |
| usingUnityEngine; | |
| publicclassright_grip : MonoBehaviour { | |
| publicGameObjectgrip1; | |
| publicfloatmSpeed1; | |
| privateRigidbodyrbody1; | |
| privatefloatinput; | |
| privateintstart_position,outerLimit,innerLimit; | |
| // Use this for initialization | |
| voidStart () { | |
| innerLimit=26; | |
| outerLimit=0; | |
| start_position=outerLimit; | |
| mSpeed1=10f; | |
| //rbody1 = GetComponent<Rigidbody>(); | |
| } | |
| // Update is called once per frame | |
| voidUpdate () { | |
| //rbody1.AddForce(0f, 0f, 1 * mSpeed1 * Input.GetAxis("Horizontal") * Time.deltaTime); | |
| input=Input.GetAxis("Horizontal"); | |
| if (input!=0) | |
| { | |
| if (input>0) | |
| { | |
| start_position++; | |
| } | |
| elseif (input<0) | |
| { | |
| start_position--; | |
| } | |
| if (start_position>=outerLimit&&start_position<=innerLimit) | |
| { | |
| transform.Translate(-1*Vector3.back*Input.GetAxis("Horizontal") *Time.deltaTime); | |
| } | |
| if (start_position>innerLimit) | |
| { | |
| start_position=innerLimit; | |
| } | |
| elseif (start_position<outerLimit) | |
| { | |
| start_position=outerLimit; | |
| } | |
| } | |
| } | |
| } |
| usingSystem.Collections; | |
| usingSystem.Collections.Generic; | |
| usingUnityEngine; | |
| publicclassleft_grip : MonoBehaviour | |
| { | |
| publicGameObjectgrip1; | |
| publicfloatmSpeed1; | |
| privateRigidbodyrbody1; | |
| privateintstart_position; | |
| privatefloatinput; | |
| privateintouterLimit, innerLimit; | |
| // Use this for initialization | |
| voidStart() | |
| { | |
| innerLimit=30; | |
| outerLimit=0; | |
| mSpeed1=10f; | |
| start_position=outerLimit; | |
| //rbody1 = GetComponent<Rigidbody>(); | |
| } | |
| // Update is called once per frame | |
| voidUpdate() | |
| { | |
| //rbody1.AddForce(0f, 0f, -1 * mSpeed1 * Input.GetAxis("Horizontal") * Time.deltaTime); | |
| input=Input.GetAxis("Horizontal"); | |
| if (input!=0) | |
| { | |
| if (input>0) | |
| { | |
| start_position++; | |
| } | |
| elseif (input<0) | |
| { | |
| start_position--; | |
| } | |
| if (start_position>=outerLimit&&start_position<=innerLimit) | |
| { | |
| transform.Translate(1*Vector3.back*Input.GetAxis("Horizontal") *Time.deltaTime); | |
| } | |
| if(start_position>innerLimit) | |
| { | |
| start_position=innerLimit; | |
| }elseif(start_position<outerLimit) | |
| { | |
| start_position=outerLimit; | |
| } | |
| } | |
| } | |
| } |
| usingSystem.Collections; | |
| usingSystem.Collections.Generic; | |
| usingUnityEngine; | |
| publicclassobjectCreator : MonoBehaviour { | |
| floatmSpeed; | |
| floatdegree; | |
| floatinput; | |
| // Use this for initialization | |
| publicGameObjectcylinder1; | |
| publicGameObjectgrip1,grip2; | |
| voidStart () { | |
| mSpeed=20f; | |
| degree=90; | |
| } | |
| // Update is called once per frame | |
| voidUpdate () { | |
| // | |
| /* | |
| float z = Input.GetAxis("Horizontal") * 15.0f; // might be negative, just test it | |
| Vector3 euler = transform.localEulerAngles; | |
| euler.z = Mathf.Lerp(euler.z, z, 2.0f * Time.deltaTime); | |
| transform.localEulerAngles = euler; | |
| */ | |
| /* | |
| input = Input.GetAxis("Vertical"); | |
| if (input > 0) | |
| { | |
| degree += 20; | |
| }else if(input < 0) | |
| { | |
| degree -= 20; | |
| } | |
| if (degree < 0) | |
| { | |
| degree = 0; | |
| } | |
| else if (degree > 180) | |
| { | |
| degree = 180; | |
| } | |
| */ | |
| transform.RotateAround(cylinder1.transform.position, Vector3.back, -1*mSpeed*Input.GetAxis("Vertical") *Time.deltaTime); | |
| } | |
| } | |
| usingSystem.Collections; | |
| usingSystem.Collections.Generic; | |
| usingUnityEngine; | |
| publicclassright_grip : MonoBehaviour { | |
| publicGameObjectgrip1; | |
| publicfloatmSpeed1; | |
| privateRigidbodyrbody1; | |
| privatefloatinput; | |
| privateintstart_position,outerLimit,innerLimit; | |
| // Use this for initialization | |
| voidStart () { | |
| innerLimit=26; | |
| outerLimit=0; | |
| start_position=outerLimit; | |
| mSpeed1=10f; | |
| //rbody1 = GetComponent<Rigidbody>(); | |
| } | |
| // Update is called once per frame | |
| voidUpdate () { | |
| //rbody1.AddForce(0f, 0f, 1 * mSpeed1 * Input.GetAxis("Horizontal") * Time.deltaTime); | |
| input=Input.GetAxis("Horizontal"); | |
| if (input!=0) | |
| { | |
| if (input>0) | |
| { | |
| start_position++; | |
| } | |
| elseif (input<0) | |
| { | |
| start_position--; | |
| } | |
| if (start_position>=outerLimit&&start_position<=innerLimit) | |
| { | |
| transform.Translate(-1*Vector3.back*Input.GetAxis("Horizontal") *Time.deltaTime); | |
| } | |
| if (start_position>innerLimit) | |
| { | |
| start_position=innerLimit; | |
| } | |
| elseif (start_position<outerLimit) | |
| { | |
| start_position=outerLimit; | |
| } | |
| } | |
| } | |
| } |
| #include<Wire.h> | |
| #include<MPU6050.h> | |
| #include<Servo.h> | |
| //--------------------- | |
| int Pot = A1; | |
| int value; | |
| //--------------------------- | |
| Servo myservo; // create servo object to control a servo | |
| MPU6050 mpu; | |
| float timeStep = 0.01; | |
| float yaw = 0; | |
| int pos = 0; // variable to store the servo position | |
| voidsetup() { | |
| myservo.attach(9); // attaches the servo on pin 9 to the servo object | |
| Serial.begin(9600); | |
| while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) | |
| { | |
| Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); | |
| delay(500); | |
| } | |
| // Calibrate gyroscope. The calibration must be at rest. | |
| // If you don't want calibrate, comment this line. | |
| mpu.calibrateGyro(); | |
| // Set threshold sensivty. Default 3. | |
| // If you don't want use threshold, comment this line or set 0. | |
| mpu.setThreshold(5); | |
| // pinMode(A0 , INPUT); | |
| } | |
| int hamoksha=0; | |
| voidloop() | |
| { | |
| Vector norm = mpu.readNormalizeGyro(); | |
| yaw = yaw + norm.ZAxis *timeStep; | |
| hamoksha=map(yaw,-80,80,0,180); | |
| hamoksha=constrain(hamoksha,0,180); | |
| myservo.write(hamoksha); | |
| //---------------------------------- | |
| value = analogRead(Pot); | |
| value=map(value,0,1023,0,255); | |
| //--------------------------- | |
| Serial.write('a'); | |
| delay(100); | |
| Serial.write(value); | |
| Serial.write('a'); | |
| delay(100); | |
| Serial.write(hamoksha); | |
| } |



SpaceApps is a NASA incubator innovation program.