View unanswered posts | View active topics It is currently Sun Dec 16, 2018 12:26 am






Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
RobotC Programming 
Author Message
Rookie

Joined: Mon Jan 05, 2015 3:46 pm
Posts: 10
Post Re: RobotC Programming
**Error**:Executable statements not valid in 'main' declaration block
**Error**:Executable statements not valid in 'main' declaration block

in lines 61 and 68


Thu Jan 08, 2015 3:20 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: RobotC Programming
This is how your latest code looked when doing a "whole file format". You can see how the braces not matching up. Unfortunately, not knowing what you intended to do, it is hard for us to try fixing it. Please look at it and put braces in the correct places.
Code:
#pragma config(Sensor, in1, Sensor1, sensorReflection)
#pragma config(Sensor, in2, Sensor2, sensorReflection)
#pragma config(Sensor, in3, Sensor3, sensorReflection)
#pragma config(Sensor, in4, Sensor4, sensorLineFollower)
#pragma config(Sensor, in5, Sensor5, sensorReflection)
#pragma config(Sensor, in6, Sensor6, sensorReflection)
#pragma config(Sensor, in7, Sensor7, sensorReflection)
#pragma config(Sensor, in8, Sensor8, sensorReflection)
#pragma config(Sensor, dgtl1, BuzzeLight, sensorDigitalOut)
#pragma config(Motor, port1, Flashlight1, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port2, buzz1, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port8, Flashlight2, tmotorVexFlashlight, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*
Project Title: Smart Goal
Team Members: Jordon Hayes, Bryce Menzer, Katie Otsuka, Calvin Nguyen
Date: December 19, 2014
Section:


Task Description: Create a goal control system that will light up when a goal is made. Must differentiate between
human and ball.


Pseudocode:

*/

task main()
{
    turnFlashlightOff(Flashlight1);
    turnFlashlightOn(Flashlight1, 127);
    turnFlashlightOn(Flashlight2, 127);

    wait(1);

    while (1 == 1) //

    if(SensorValue[Sensor2] >= 120)

    waitInMilliseconds(5);

    clearTimer(T1);
}
if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
{
    waitInMilliseconds(5);
    turnFlashlightOn(buzz1, 127);
    wait(10);
    turnFlashlightOff(buzz1);
}

else

if(SensorValue[Sensor1] >= 120)
{
    waitInMilliseconds(5);

    clearTimer(T1);
}
if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
{
    waitInMilliseconds(5);
    turnFlashlightOn(buzz1, 127);
    wait(10);
    turnFlashlightOff(buzz1);
}


Thu Jan 08, 2015 3:40 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: RobotC Programming
This is one way to fix it but I am not sure it's correct without knowing your intention.
Code:
task main()
{
    turnFlashlightOff(Flashlight1);
    turnFlashlightOn(Flashlight1, 127);
    turnFlashlightOn(Flashlight2, 127);
    wait(1);
    while (1 == 1)
    {
        if(SensorValue[Sensor2] >= 120)
        {
            waitInMilliseconds(5);
            clearTimer(T1);
        }
        if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
        {
            waitInMilliseconds(5);
            turnFlashlightOn(buzz1, 127);
            wait(10);
            turnFlashlightOff(buzz1);
        }
        else if(SensorValue[Sensor1] >= 120)
        {
            waitInMilliseconds(5);
            clearTimer(T1);
        }
        if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
        {
            waitInMilliseconds(5);
            turnFlashlightOn(buzz1, 127);
            wait(10);
            turnFlashlightOff(buzz1);
        }
    }
}


Thu Jan 08, 2015 3:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 18 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.