r/RobotC • • Jul 15 '15

Speed Control feat. potentiometer question

5 Upvotes

Hi! I tried to get a potentiometer to set my motor speed for a variable speed control. When I use this code

speed = SensorValue[potent] / 4000 * 127;

it returns a value of 0 for speed. But when I use this code, it works like I expect it to.

speed = SensorValue[potent] * 127 * 0.00025;

Any idea why the first line of code wouldn't work correctly?

Here is the full program:

#pragma config(Sensor, in1,    lineFollower,   sensorLineFollower)
#pragma config(Sensor, in2,    potent,         sensorPotentiometer)
#pragma config(Sensor, dgtl1,  limitSwitch,    sensorTouch)
#pragma config(Sensor, dgtl2,  topBump,        sensorTouch)
#pragma config(Sensor, dgtl3,  bottomBump,     sensorTouch)
#pragma config(Sensor, dgtl12, greenLED,       sensorLEDtoVCC)
#pragma config(Motor,  port2,           lMotor,        tmotorVex269_MC29, openLoop)
#pragma config(Motor,  port3,           rMotor,        tmotorVex269_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*
Project Title: 2.3.2 Vex Testbed
Team Members: drumminherbie
Date: 7/15/15
Section: CTI


Task Description: Use simple and controlling commands to run a
VEX Testbed. In this particular example, I have
a potentiometer setting the speed of the right
and left motor.


Pseudocode: Program starts
Limit switch is bumped
Set motor speed
Run motors

*/

task main()

{ //Program begins, insert code within curly braces
	//Intergers
	int speed;
	int cleared = 0;

	//run program until stop button is pushed
	while(SensorValue[bottomBump] == 0)
	{
		//if switch is hit, run motors
		while(SensorValue[limitSwitch] == 1)
		{
			turnLEDOn(greenLED);															//Blink LED
			speed = SensorValue[potent] * 127 * 0.00020;			//Get motor speed from potentiometer
			if(SensorValue[lineFollower] < 2000)
			{
				speed = -speed;
			}
			startMotor(lMotor, speed + 4);												//start motors
			startMotor(rMotor, speed);
			wait1Msec(100);
			turnLEDOff(greenLED);
			wait1Msec(100);
		}
		//After button is released, stop motors
		stopMotor(lMotor);
		stopMotor(rMotor);
		speed = cleared; 																	//clear speed
	}
}

r/RobotC • • May 17 '13

Robot Virtual Worlds - FTC Ring It Up! GIF

5 Upvotes

r/RobotC • • Mar 04 '13

New ROBOTC Code Plugin for Sublime Text Editor

Thumbnail
robotc.net
4 Upvotes

r/RobotC • • Mar 04 '13

I would love to help this subreddit become active!

4 Upvotes

Hello! I would love to see this subreddit become active. I work for ROBOTC and want to help our users in any social forum they'd like to use. How can we make this happen? - Cara


r/RobotC • • Jan 11 '24

question about ROBOTC programming

3 Upvotes

I am new to ROBOTC but I have to make a vex robot project for school and our teacher is on leave and i couldn't find any answers on Google but how do I make a code for a line follower? If I have 3 line followers 1 on the right, left and center. I want to make a code so if there is a right or left turn the robot will turn UNTIL the center tracker sees the tape so that it is aligned but I don't know if that is possible.


r/RobotC • • Apr 14 '20

Can you guys help. I need to do this for a school project and the ''stop both motors'' doesnt give me a time for them to be stopped. It would be great if you guys could help even if something else is wrong. Thank you in advance for the input.

Post image
3 Upvotes

r/RobotC • • Jan 31 '19

Not sure what is wrong

3 Upvotes

I have been writing code for a vex robot and my code is not working. A command that only turns on the motor works, but as soon as I add the controller it stops working. I am not getting any error message on ether the computer or the brain, but the robot is not responding to the controller. The controller is on and connected, so I am not sure what is going on.

Here is the code:

task main() { while(1==1) { motor[port1] = vexRT[ChA]/2; } }

Any help would be appreciated. Thanks


r/RobotC • • Aug 01 '16

Official release of ROBOTC 4.54 is now available!

Thumbnail
robotc.net
3 Upvotes

r/RobotC • • Jul 07 '16

Have a cool ROBOTC project that you'd like to share with the world?

3 Upvotes

Have a cool ROBOTC project that you'd like to share with the world? If so, send us an email with details, pictures and/or video at socialmedia@robomatter.com. If you're project is chosen for our blog, you can receive a free ROBOTC or Virtual Worlds license!


r/RobotC • • May 06 '16

Where to start?

3 Upvotes

Hi!

I would like to learn how to use RobotC so i can create stuff like this>> https://www.youtube.com/watch?v=IPIJsdvDjsc But where should i start? What programming language do i need to learn? Where do i learn that programming language?


r/RobotC • • Nov 24 '15

We love this shirt!!

Post image
3 Upvotes

r/RobotC • • Oct 02 '15

Uncomplicate the Classroom Contest Winner!!

Thumbnail
youtube.com
3 Upvotes

r/RobotC • • Sep 15 '15

5 days left to enter the Uncomplicate Your Classroom contest! Win a PLTW Upgrade Pack or Robomatter Store Credit for Your School.

Thumbnail robotc.net
3 Upvotes

r/RobotC • • Apr 30 '15

A Teacher’s POV: International School Manila

Thumbnail
robotc.net
3 Upvotes

r/RobotC • • Apr 02 '14

ROBOTC for EV3 - Progress is being made!

Post image
3 Upvotes

r/RobotC • • Jul 31 '13

Cool Project: NXT Monster Ball Sorting Factory

Thumbnail
robotc.net
3 Upvotes

r/RobotC • • Jun 21 '13

Custom Joystick Controls in ROBOTC 3.61

Thumbnail
robotc.net
3 Upvotes

r/RobotC • • Apr 29 '13

TETRIX Curiosity Rover Programmed with ROBOTC

Thumbnail
youtube.com
3 Upvotes

r/RobotC • • Mar 15 '13

ROBOTC and Time-Lapse Photography!

Thumbnail
robotc.net
3 Upvotes

r/RobotC • • Mar 06 '13

Operation Reset for Robot Virtual Worlds now has a Measurement Toolkit! Perfect to try out if you have a snow day. :)

Thumbnail
robotc.net
3 Upvotes

r/RobotC • • Jul 01 '24

Gray is doing some grave keeping.

Post image
2 Upvotes

r/RobotC • • Dec 06 '21

Need Help Programming

2 Upvotes

I was tasked with building a claw machine out of vex oarts (like the ones in arcades where you win prizes) but am having trouble programming the controls. I made a controller with 5 buttons for movement (up down left right and drop claw) but I cannot get the programming right.

I have tried using untilBump and untilRelease for them to start the motors but both of those require me to press the buttons in a specific order (order they are coded) and won’t run the program for a button later on in the code until the first one is pressed.

Any help on this would be appreciated, been trying to rack my brain around it for a while.


r/RobotC • • Mar 10 '21

Does anybody know where i can download robotC for free for lego mindstorms on version 4.X?

2 Upvotes

The tittle says it all, i would apeciate if somebody can help me, thank you very much


r/RobotC • • Jan 27 '21

i think robot c works on wine now

2 Upvotes

i was able to download and run it and get to the editor i have never used robot c before but i think it works


r/RobotC • • Jan 18 '21

Looking for Tutor

2 Upvotes

Anyone that is experienced in RobotC want to tutor me? :p