View unanswered posts | View active topics It is currently Tue Aug 04, 2020 2:20 am

Reply to topic  [ 2 posts ] 
Help with finishing simple code BOE Bot 
Author Message

Joined: Wed Jun 11, 2014 4:15 pm
Posts: 1
Post Help with finishing simple code BOE Bot
I have a BOE Bot with arduino and I'm trying to program it via ROBOTC to use the light chasing sensors and also flash the led lights while it is going. I was looking to put the speaker in too for sound but I don't know how to do that. My problem is the light sensors and the LED Lights both say task main () so they won't work simultaneously on the bot. I keep getting the error message - **Error**:Duplicate definition for task 'main'. I have pasted my whole code below. Thank you!

#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(PluginCircuitBoard, typeShieldParallaxBoeBot)
#pragma config(Sensor, anlg0,  leftLight,      sensorReflection)
#pragma config(Sensor, anlg1,  rightLight,     sensorReflection)
#pragma config(Sensor, dgtl5,  led1,           sensorDigitalOut)
#pragma config(Sensor, dgtl6,  led2,           sensorDigitalOut)
#pragma config(Motor,  servo_10,        leftServo,     tmotorServoContinuousRotation, openLoop, IOPins, dgtl10, None)
#pragma config(Motor,  servo_11,        rightServo,    tmotorServoContinuousRotation, openLoop, reversed, IOPins, dgtl11, None)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

 task main()
    int factor = 120; //This value worked for us however you might want to change it for your robot/flashlight intensity.
    int shadeDiff = ((SensorValue[rightLight] * factor) / (SensorValue[leftLight] + SensorValue[rightLight]) - (factor / 2)) * 2;
    motor[leftServo] = 20 + shadeDiff;
    motor[rightServo] = 20 - shadeDiff;
    //If the loop cycles too quickly, we get calculation errors. Therefore we regulate the speed by waiting a bit.

task main()
  while(true) //repeat indefinitely
    //turn led1 on
    SensorValue[led1] = true;

    //turn led2 off
    SensorValue[led2] = false;

    //wait 1 second

    //turn the led1 off
    SensorValue[led1] = false;

    //turn led2 on
    SensorValue[led2] = true;

    //wait 1 second

Wed Jun 11, 2014 4:51 pm

Joined: Thu Jan 02, 2014 5:07 pm
Posts: 11
Post Re: Help with finishing simple code BOE Bot
That error code is correct. You have two main tasks declared:

task main()

You can only have one main task declared. You need to integrate the second one's code into the first one and then delete that second main task.

(Analog Digital Continuously Automous Robot)
Whew, Gary, the answer is still 42!

Tue Sep 02, 2014 4:43 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

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.