Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   My sensors don't work (http://www.chiefdelphi.com/forums/showthread.php?t=17351)

Fares 03-02-2003 17:21

My sensors don't work
 
I tried installing the sensors on the EDU and test them out, but the coding doesn't seem to be working


this is what i have:

if c_sensor1=1 then c_p1_y=1

what's wrong with this code if it keeps telling me that it expects a label


:ahh:

DanL 03-02-2003 17:41

try using just 'sensor1' and 'p1_y'

And also, it seems like you're trying to make the robot go forward when the sensor is active. Since p1_y is a analogue input/output, it goes from 0 to 254 (note: a common mistake for rookies - including us last year - is thinking that PWM outputs go up to 255. Although TECHNICALLY right (analogue-wise), it's a, uh, how do I put this... *bright flashing red lights*<b>bad</b> thing to output that). Anyways, if you're outputing p1_y to a PWM port, make it equal to 254.

Greg Ross 03-02-2003 18:26

Re: My sensors don't work
 
Quote:

Originally posted by Fares
I tried installing the sensors on the EDU and test them out, but the coding doesn't seem to be working


this is what i have:

if c_sensor1=1 then c_p1_y=1

what's wrong with this code if it keeps telling me that it expects a label


:ahh:

A couple of problems: Both c_sensor1 and c_p1_y are CONSTANTS used in initialization to set up communications with the master microprocessor. You're not going to be able to SET c_p1_y. You should use if sensor1=1 then p1_y=1 as SuperDanman suggested.

Also, since you are using PBASIC v2.5 syntax (if ... then ... statement) rather than v2.0 (if ... then ... label), you need to enable 2.5 syntax by including a '{$PBASIC 2.5} directive. (If 2.5 syntax had been enabled, the error message would have said: "Expected a label, variable, or instruction" instead of "Expected a label".)


All times are GMT -5. The time now is 15:15.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi