'**************************************************************** '* Name : BlimpBotEasyRadioRX for PIC18F252 * '* Author : Leif & Jury * '* Notice : Copyright (c) 2006 * '* : All Rights Reserved * '* Date : 4/9/2006 * '* Version : 6.0 * '* Notes : * '* : now with SEPARATE laterialControl * '**************************************************************** 'RX Tranceiver INCLUDE "modedefs.bas" DEFINE OSC 20 ' ----------------- ' Define FR connection speed ' ----------------- RFbaud CON 32 'RF connection speed RFTX var PORTC.4 'pin to transmit serial from PIC to RF RFRX VAR PORTC.5 'pin to transmit serial from RF to PIC CPUbaud CON 16468 'CPU serial connection speed CPURX VAR PORTC.7 'pin to transmit serial from CPU to PIC CPUTX VAR PORTC.6 'pin to transmit serial from PIC to CPU indicatorLED var PORTC.2 OUTPUT indicatorLED 'set indicatorLED pin to output output RFTX 'set RFTX pin to output input RFRX 'set RFRX pin to input OUTPUT CPUTX 'set CPUTX pin to output INPUT CPURX 'set CPURX pin to input TRISB = %00000000 'set all pins on port b to output PORTB = %00000000 'bring all b pins low to start ' ----------------- ' Counter variable ' ----------------- inByte var byte ' ----------------- ' Blink the test pin ' ----------------- high indicatorLED pause 500 low indicatorLED pause 500 serout2 CPUTX, CPUbaud,["Serial comunication established to computer...", 13,10] ' ----------------- ' setup the RF channel ' ----------------- serout2 RFTX, RFbaud,0,["ER_CMD#C4"] pause 20 serout2 RFTX, RFbaud,0,["ACK"] serout2 CPUTX, CPUbaud,["Setup complete...", 13, 10] ' ----------------- MAIN: serin2 RFRX, RFbaud,[STR inByte\1] serout2 CPUTX, CPUbaud,[dec inByte, 13, 10] SELECT CASE inByte case 30 'up arrow ascii go forward turn motor a&b on 'PORTB = %00000101 High PORTB.0 low PORTB.1 HIGH PORTB.2 Low PORTB.3 CASE 31 'down arrow ascii go backward turn motor c&d on 'PORTB = %00001010 low PORTB.0 HIGH PORTB.1 LOW PORTB.2 HIGH PORTB.3 CASE 28 'left arrow ascii turn left turn motor b&d on ;PORTB = %00001001 HIGH PORTB.0 LOW PORTB.1 LOW PORTB.2 LOW PORTB.3 CASE 29 'right arrow ascii turn right turn on motor a&c 'PORTB = %00000110 LOW PORTB.0 LOW PORTB.1 HIGH PORTB.2 LOW PORTB.3 Case 46 '. key for vertical up 'PORTB = %01010000 HIGH PORTB.4 LOW PORTB.5 HIGH PORTB.6 LOW PORTB.7 case 44 ', key for vertical down 'PORTB = %10100000 LOW PORTB.4 HIGH PORTB.5 LOW PORTB.6 HIGH PORTB.7 CASE 81 'q key cuts horizontal motors LOW PORTB.0 LOW PORTB.1 LOW PORTB.2 LOW PORTB.3 CASE 47 '/ KEY CUTS VERTICAL MOTORS LOW PORTB.4 LOW PORTB.5 LOW PORTB.6 LOW PORTB.7 CASe 32 'space bar ascii stop all motors PORTB = %00000000 end select goto main