Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
u08 myReceivedByte;
if (uartReceiveByte(&myReceivedByte)) { // if there are bytes waiting on the serial port char inByte = uartGetByte(); // read a byte if (inByte == 'r') { //if that byte is the desired character hold_position(); // stop the robot delay_cycles(336000); //two second wait delay resetChip(5); // reset the chip after waiting for the specified # of seconds } // end if if (inByte == 'h' ) { hold_position(); } } // end if
Why do I reset the chip?
Also, how do I do it on the computer side?
u08 myReceivedByte;int servo_1=600;void control(void) { while(1) { if (uartReceiveByte(&myReceivedByte)) // if there are bytes waiting on the serial port { char inByte = uartGetByte(); // read a byte if (inByte == 'r') //if that byte is the desired character { servo_1=300; } // end if if (inByte == 'h' ) { servo_1=1000; } } // end if } }
../control.c:24: warning: passing argument 1 of 'uartReceiveByte' makes integer from pointer without a cast../control.c:24: error: too few arguments to function 'uartReceiveByte'
if (uartReceiveByte(&myReceivedByte)) // if there are bytes waiting on the serial port
../control.c:24: warning: passing argument 1 of 'uartReceiveByte' makes integer from pointer without a cast
if (uartReceiveByte(1, &myReceivedByte)) // if there are bytes waiting on the serial port
QuoteAlso, how do I do it on the computer side?open up Hyperterminal, connect to the Axon, type 'r', press enter, done.
temp=uart1GetByte();//returns -1 if no data presentif (temp == r)//if data received do_stuff();
u08 myReceivedByte;void control(void) { while(1) { if (uartReceiveByte(1,&myReceivedByte)) // if there are bytes waiting on the serial port { char inByte = uart1GetByte(); // read a byte if (inByte == 'l') //if that byte is the desired character { LED_on(); } // end if if (inByte == 'o' ) { LED_off(); } } // end if }}
But the problem I'm having is I can't even type anything into hyperterminal.
void control(void) { while(1) { char cByte = uart1GetByte(); // get byte from UART1 on the axon if (cByte == 'l') // if character received is l then { LED_on(); } if (cByte == 'o') { LED_off(); } }}
long unsigned int servo_1=700;void servo_right(void) { servo_1=280; }void servo_left(void) { servo_1=1119; }void control(void) { while(1) { char cByte = uart1GetByte(); // get byte from UART1 on the axon if (cByte == 'r') // if character received is b then { servo_right(); LED_on(); } if (cByte == 'l') { servo_left(); LED_off(); } }}
The Led turns on and off when they're supposed to but the servo doesn't react. Anybody know why, and how to fix it?
servo_1(servo_1);
void control(void) { while(1) { char cByte = uart1GetByte(); // get byte from UART1 on the axon if (cByte == 'r') // if character received is b then { servo_right(); LED_on(); } if (cByte == 'l') { servo_left(); LED_off(); } }}The Led turns on and off when they're supposed to but the servo doesn't react. Anybody know why, and how to fix it?
void control(void){ //photovore();//run photovore algorithm, or comment out for your own code while(1) { char cByte = uart1GetByte(); // get byte from UART1 on the axon if (cByte == 'y') // if character received is "y" then { LED_on(); // turn on the green led rprintf("\r\n Led on \r\n"); //send Led on to the USB port } if (cByte == 'c') // if it is "c" { servo(PORTA,7,700); // center the servo on port a7 delay_ms(20); // and pause for 20 milliseconds before repeating rprintf("\r\n A7 centered \r\n"); //send A7 centered to the USB port } if (cByte == 'n') // if it is "n" { LED_off(); // turn off the green led rprintf("\r\n led not on \r\n"); //send led not on to the USB port } }}
Jdog,I used some of your code in the following and added a little feedback to the port. One issue I have is that I have to send the c 2 times to get the servo to center or move at all. while the led on and off work with a single character. The feedback works fine on every character sent. Any ideas??
Thanks again for Showing what you are doing.Wizzard
int GetByte(void) {//Syntax is variable= GetByte(); where variable is any variable capable of storing a bytewhile((UCSR0A&(1<<RXC0)) == 0); // wait until a byte is receivedreturn UDR0; // once a byte is received send back to the program the byte}// Just change the 0 of USCR0A, RXC0, and UDR0 to your UART port number
You can learn Visual Basic, create a computer program that can read whatever keystrokes you want and output them (including arrays) to the Axon.
Quote from: Razor Concepts on February 28, 2009, 12:44:46 PMYou can learn Visual Basic, create a computer program that can read whatever keystrokes you want and output them (including arrays) to the Axon.How would you have the axon receive an array from the computer.