-
Notifications
You must be signed in to change notification settings - Fork 0
/
A3_1_3_Part6.c
38 lines (33 loc) · 1.81 KB
/
A3_1_3_Part6.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma config(Sensor, in1, lineFollower, sensorLineFollower)
#pragma config(Sensor, in2, potentiometer, sensorPotentiometer)
#pragma config(Sensor, in3, lightSensor, sensorReflection)
#pragma config(Sensor, dgtl1, limitSwitch, sensorTouch)
#pragma config(Sensor, dgtl2, bumpSwitch, sensorTouch)
#pragma config(Sensor, dgtl3, quad, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, sonar, sensorSONAR_inch)
#pragma config(Sensor, dgtl12, green, sensorLEDtoVCC)
#pragma config(Motor, port1, flashlight, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port2, rightMotor, tmotorVex269_MC29, openLoop)
#pragma config(Motor, port3, leftMotor, tmotorVex269_MC29, openLoop)
#pragma config(Motor, port9, servoMotor, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
Project Title: PLTW POE Programming
Team Members: Brandon Takahashi, Ryan Frey, Jaiden Cochenour
Date: 5/2/16
Section: 3.1.1
Task Description:
Learning how to use a sonar sensor
Pseudocode:
Wait for the sonar sensor to detect object within 20cm, then starts the motors
Waits again for the sonar sensor to detect said object outside of 25cm , then stops the motors
*/
task main()
{ //Program begins, insert code within curly braces
untilSonarLessThan(20, sonar); //waits for the sonar sensor todetect an object within 20cm
startMotor(leftMotor, 63); //turns on left motor
startMotor(rightMotor, 63); //turns on right motor
untilSonarGreaterThan(25, sonar); //waits for the object to move to a distance greater than 25cm
stopMotor(leftMotor); //Stops left motor
stopMotor(rightMotor); //Stops right motor
}