Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
/*************************************************************************AXON AND AXON II CODE FOR WEBBOTLIBAuthored by John Palmisano of SocietyofRobots.comin collaboration with Clive Webster of WebbotLib.For more information, see:http://www.societyofrobots.com/axonhttp://www.societyofrobots.com/axon2http://sourceforge.net/projects/webbotavrclib2009intended use for Axon and Axon IIinstructions:Read comments for explanation of all code.appInitHardware() is for initiating the Axon.appControl() is where your code goes. It is similar to control.cfor the original Axon code.See hardware.h for defining your external hardware.See sys/axon2.h in WebbotLib to change which pins are input and output.*************************************************************************///allows for printing with features, but uses more memory#define RPRINTF_FLOAT#define RPRINTF_COMPLEX//additional math capabilities//#include <math.h>//WebbotLib includes//#include "sys/axon.h" //use for original Axon#include "sys/axon2.h" //defines your MCU (change to axon.h if you use the original Axon)#include "servos.h" //use for servos#include "a2d.h" //use for ADC#include "rprintf.h" //use for UART#include "i2c_master.h" //use for I2C//#include "buffer.h" //use for GPS and other serial stuff//user includes#include "hardware.h"// In my initialising code - pass the list of servos to controlvoid appInitHardware(void) { //initialize UART ports (see hardware.h to change baud/names) uartInit(GPS_UART, GPS_BAUD); //UART0 uartInit(USB_UART, USB_BAUD); //USB uartInit(WIRELESS_UART, WIRELESS_BAUD); //UART2 uartInit(OTHER_UART, OTHER_BAUD); //UART3 // declare USB for output rprintfInit(USB_ACTIVATE); // Initialise the servo controller servoPWMInit(&bank1); //use PWM to control servos (must use PWM pins!) //servosInit(&bank1, TIMER1); //use software PWM to control servos (can use any pin) // Initiate Sensors (examples commented out) //accelerometerInit(accm3d2); //compassInit(hmc6343); //gyroInit(idg300); }TICK_COUNT appInitSoftware(TICK_COUNT loopStart){ rprintf("\nAxon Initiated.\n\n");return 0;}//the larger this number, the more likely your robot will drive straight#define threshold 8// This is the main loopTICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { servosDisconnect(&bank1);//turn servos off delay_ms(100);//button debounce delay rprintf("\nPush Button to Start\n"); while(!button_pressed());//wait for button to be pressed servosConnect(&bank1);//turn servos on delay_ms(100);//button debounce delay while(!button_pressed())//exit code if button is pushed { update_sensors(); if(lightLeft > lightRight && (lightLeft - lightRight) > threshold) { // go left act_setSpeed(&left_wheel,DRIVE_SPEED_MIN); act_setSpeed(&right_wheel,DRIVE_SPEED_MAX); led_put_char(1); } else if(lightRight > lightLeft && (lightRight - lightLeft) > threshold) { // go right act_setSpeed(&left_wheel,DRIVE_SPEED_MAX); act_setSpeed(&right_wheel,DRIVE_SPEED_MIN); led_put_char(3); } else { // Go forwards act_setSpeed(&left_wheel,DRIVE_SPEED_MAX); act_setSpeed(&right_wheel,DRIVE_SPEED_MAX); led_put_char(2); } //print out detected difference rprintf("Sensor Difference: %d\n", lightLeft - lightRight); delay_ms(30);//slow control loop down to prevent crazy robot oscillation } return 20000; // wait for 20ms to stop crazy oscillations (long story) }
Now, right click 'Header Files' and left click 'Add Existing Source File(s)...'. Add hardware.h from the photovore example folder.
if you have it, make sure it is in the same folder as the rest of your code (the .c file, excluding the webbot-lib stuff).
did what I said solve it? just for others it would be nice to say what fixed it.